1
0

google.php 34 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562
  1. <?php
  2. class google{
  3. private const is_class = ".";
  4. private const is_id = "#";
  5. public function __construct(){
  6. include "lib/fuckhtml.php";
  7. $this->fuckhtml = new fuckhtml();
  8. include "lib/nextpage.php";
  9. $this->nextpage = new nextpage("google");
  10. }
  11. public function getfilters($page){
  12. switch($page){
  13. case "web": return [];/*
  14. return [
  15. "country" => [
  16. "display" => "Country",
  17. "option" => [
  18. "zz" => "Instance region",
  19. "af" => "Afghanistan",
  20. "al" => "Albania",
  21. "dz" => "Algeria",
  22. "as" => "American Samoa",
  23. "ad" => "Andorra",
  24. "ao" => "Angola",
  25. "ag" => "Antigua & Barbuda",
  26. "ar" => "Argentina",
  27. "am" => "Armenia",
  28. "au" => "Australia",
  29. "at" => "Austria",
  30. "az" => "Azerbaijan",
  31. "bs" => "Bahamas",
  32. "bh" => "Bahrain",
  33. "bd" => "Bangladesh",
  34. "by" => "Belarus",
  35. "be" => "Belgium",
  36. "bz" => "Belize",
  37. "bj" => "Benin",
  38. "bt" => "Bhutan",
  39. "bo" => "Bolivia",
  40. "ba" => "Bosnia & Herzegovina",
  41. "bw" => "Botswana",
  42. "br" => "Brazil",
  43. "bn" => "Brunei",
  44. "bg" => "Bulgaria",
  45. "bf" => "Burkina Faso",
  46. "bi" => "Burundi",
  47. "kh" => "Cambodia",
  48. "cm" => "Cameroon",
  49. "ca" => "Canada",
  50. "cv" => "Cape Verde",
  51. "cf" => "Central African Republic",
  52. "td" => "Chad",
  53. "cl" => "Chile",
  54. "co" => "Colombia",
  55. "cg" => "Congo - Brazzaville",
  56. "cd" => "Congo - Kinshasa",
  57. "ck" => "Cook Islands",
  58. "cr" => "Costa Rica",
  59. "ci" => "Côte d’Ivoire",
  60. "hr" => "Croatia",
  61. "cu" => "Cuba",
  62. "cy" => "Cyprus",
  63. "cz" => "Czechia",
  64. "dk" => "Denmark",
  65. "dj" => "Djibouti",
  66. "dm" => "Dominica",
  67. "do" => "Dominican Republic",
  68. "ec" => "Ecuador",
  69. "eg" => "Egypt",
  70. "sv" => "El Salvador",
  71. "ee" => "Estonia",
  72. "et" => "Ethiopia",
  73. "fj" => "Fiji",
  74. "fi" => "Finland",
  75. "fr" => "France",
  76. "ga" => "Gabon",
  77. "gm" => "Gambia",
  78. "ge" => "Georgia",
  79. "de" => "Germany",
  80. "gh" => "Ghana",
  81. "gi" => "Gibraltar",
  82. "gr" => "Greece",
  83. "gl" => "Greenland",
  84. "gt" => "Guatemala",
  85. "gg" => "Guernsey",
  86. "gy" => "Guyana",
  87. "ht" => "Haiti",
  88. "hn" => "Honduras",
  89. "hk" => "Hong Kong",
  90. "hu" => "Hungary",
  91. "is" => "Iceland",
  92. "in" => "India",
  93. "id" => "Indonesia",
  94. "iq" => "Iraq",
  95. "ie" => "Ireland",
  96. "im" => "Isle of Man",
  97. "il" => "Israel",
  98. "it" => "Italy",
  99. "jm" => "Jamaica",
  100. "jp" => "Japan",
  101. "je" => "Jersey",
  102. "jo" => "Jordan",
  103. "kz" => "Kazakhstan",
  104. "ke" => "Kenya",
  105. "ki" => "Kiribati",
  106. "kw" => "Kuwait",
  107. "kg" => "Kyrgyzstan",
  108. "la" => "Laos",
  109. "lv" => "Latvia",
  110. "lb" => "Lebanon",
  111. "ls" => "Lesotho",
  112. "ly" => "Libya",
  113. "li" => "Liechtenstein",
  114. "lt" => "Lithuania",
  115. "lu" => "Luxembourg",
  116. "mg" => "Madagascar",
  117. "mw" => "Malawi",
  118. "my" => "Malaysia",
  119. "mv" => "Maldives",
  120. "ml" => "Mali",
  121. "mt" => "Malta",
  122. "mu" => "Mauritius",
  123. "mx" => "Mexico",
  124. "fm" => "Micronesia",
  125. "md" => "Moldova",
  126. "mn" => "Mongolia",
  127. "me" => "Montenegro",
  128. "ma" => "Morocco",
  129. "mz" => "Mozambique",
  130. "mm" => "Myanmar (Burma)",
  131. "na" => "Namibia",
  132. "nr" => "Nauru",
  133. "np" => "Nepal",
  134. "nl" => "Netherlands",
  135. "nz" => "New Zealand",
  136. "ni" => "Nicaragua",
  137. "ne" => "Niger",
  138. "ng" => "Nigeria",
  139. "nu" => "Niue",
  140. "mk" => "North Macedonia",
  141. "no" => "Norway",
  142. "om" => "Oman",
  143. "pk" => "Pakistan",
  144. "ps" => "Palestine",
  145. "pa" => "Panama",
  146. "pg" => "Papua New Guinea",
  147. "py" => "Paraguay",
  148. "pe" => "Peru",
  149. "ph" => "Philippines",
  150. "pn" => "Pitcairn Islands",
  151. "pl" => "Poland",
  152. "pt" => "Portugal",
  153. "pr" => "Puerto Rico",
  154. "qa" => "Qatar",
  155. "ro" => "Romania",
  156. "ru" => "Russia",
  157. "rw" => "Rwanda",
  158. "ws" => "Samoa",
  159. "sm" => "San Marino",
  160. "st" => "São Tomé & Príncipe",
  161. "sa" => "Saudi Arabia",
  162. "sn" => "Senegal",
  163. "rs" => "Serbia",
  164. "sc" => "Seychelles",
  165. "sl" => "Sierra Leone",
  166. "sg" => "Singapore",
  167. "sk" => "Slovakia",
  168. "si" => "Slovenia",
  169. "sb" => "Solomon Islands",
  170. "so" => "Somalia",
  171. "za" => "South Africa",
  172. "kr" => "South Korea",
  173. "es" => "Spain",
  174. "lk" => "Sri Lanka",
  175. "sh" => "St. Helena",
  176. "vc" => "St. Vincent & Grenadines",
  177. "sr" => "Suriname",
  178. "se" => "Sweden",
  179. "ch" => "Switzerland",
  180. "tw" => "Taiwan",
  181. "tj" => "Tajikistan",
  182. "tz" => "Tanzania",
  183. "th" => "Thailand",
  184. "tl" => "Timor-Leste",
  185. "tg" => "Togo",
  186. "to" => "Tonga",
  187. "tt" => "Trinidad & Tobago",
  188. "tn" => "Tunisia",
  189. "tr" => "Türkiye",
  190. "tm" => "Turkmenistan",
  191. "vi" => "U.S. Virgin Islands",
  192. "ug" => "Uganda",
  193. "ua" => "Ukraine",
  194. "ae" => "United Arab Emirates",
  195. "gb" => "United Kingdom",
  196. "us" => "United States",
  197. "uy" => "Uruguay",
  198. "uz" => "Uzbekistan",
  199. "vu" => "Vanuatu",
  200. "ve" => "Venezuela",
  201. "vn" => "Vietnam",
  202. "zm" => "Zambia",
  203. "zw" => "Zimbabwe"
  204. ]
  205. ],
  206. "nsfw" => [
  207. "display" => "NSFW",
  208. "option" => [
  209. "yes" => "Yes",
  210. "no" => "No"
  211. ]
  212. ],
  213. "lang" => [ // prefix with lang_
  214. "display" => "Language",
  215. "option" => [
  216. "any" => "Any language",
  217. "af" => "Afrikaans",
  218. "ca" => "català",
  219. "cs" => "čeština",
  220. "da" => "dansk",
  221. "de" => "Deutsch",
  222. "et" => "eesti",
  223. "en" => "English",
  224. "es" => "español",
  225. "eo" => "esperanto",
  226. "tl" => "Filipino",
  227. "fr" => "français",
  228. "hr" => "hrvatski",
  229. "id" => "Indonesia",
  230. "is" => "íslenska",
  231. "it" => "italiano",
  232. "sw" => "Kiswahili",
  233. "lv" => "latviešu",
  234. "lt" => "lietuvių",
  235. "hu" => "magyar",
  236. "nl" => "Nederlands",
  237. "no" => "norsk",
  238. "pl" => "polski",
  239. "pt" => "português",
  240. "ro" => "română",
  241. "sk" => "slovenčina",
  242. "sl" => "slovenščina",
  243. "fi" => "suomi",
  244. "sv" => "svenska",
  245. "vi" => "Tiếng Việt",
  246. "tr" => "Türkçe",
  247. "el" => "Ελληνικά",
  248. "be" => "беларуская",
  249. "bg" => "български",
  250. "ru" => "русский",
  251. "sr" => "српски",
  252. "uk" => "українська",
  253. "hy" => "հայերեն",
  254. "iw" => "עברית",
  255. "ar" => "العربية",
  256. "fa" => "فارسی",
  257. "hi" => "हिन्दी",
  258. "th" => "ไทย",
  259. "ko" => "한국어",
  260. "zh-CN" => "中文 (简体)",
  261. "zh-TW" => "中文 (繁體)",
  262. "ja" => "日本語"
  263. ]
  264. ],
  265. "time" => [
  266. "display" => "Time posted",
  267. "option" => [
  268. "any" => "Any time",
  269. "h" => "Last hour",
  270. "d" => "Last 24 hours",
  271. "w" => "Last week",
  272. "m" => "Last month",
  273. "y" => "Last year"
  274. ]
  275. ],
  276. "verbatim" => [
  277. "display" => "Verbatim",
  278. "option" => [
  279. "no" => "No",
  280. "yes" => "Yes"
  281. ]
  282. ]
  283. ];*/
  284. break;
  285. case "images":
  286. return [
  287. "country" => [ // gl=<country>
  288. "display" => "Country",
  289. "option" => [
  290. "any" => "Instance's country",
  291. "af" => "Afghanistan",
  292. "al" => "Albania",
  293. "dz" => "Algeria",
  294. "as" => "American Samoa",
  295. "ad" => "Andorra",
  296. "ao" => "Angola",
  297. "ai" => "Anguilla",
  298. "aq" => "Antarctica",
  299. "ag" => "Antigua and Barbuda",
  300. "ar" => "Argentina",
  301. "am" => "Armenia",
  302. "aw" => "Aruba",
  303. "au" => "Australia",
  304. "at" => "Austria",
  305. "az" => "Azerbaijan",
  306. "bs" => "Bahamas",
  307. "bh" => "Bahrain",
  308. "bd" => "Bangladesh",
  309. "bb" => "Barbados",
  310. "by" => "Belarus",
  311. "be" => "Belgium",
  312. "bz" => "Belize",
  313. "bj" => "Benin",
  314. "bm" => "Bermuda",
  315. "bt" => "Bhutan",
  316. "bo" => "Bolivia",
  317. "ba" => "Bosnia and Herzegovina",
  318. "bw" => "Botswana",
  319. "bv" => "Bouvet Island",
  320. "br" => "Brazil",
  321. "io" => "British Indian Ocean Territory",
  322. "bn" => "Brunei Darussalam",
  323. "bg" => "Bulgaria",
  324. "bf" => "Burkina Faso",
  325. "bi" => "Burundi",
  326. "kh" => "Cambodia",
  327. "cm" => "Cameroon",
  328. "ca" => "Canada",
  329. "cv" => "Cape Verde",
  330. "ky" => "Cayman Islands",
  331. "cf" => "Central African Republic",
  332. "td" => "Chad",
  333. "cl" => "Chile",
  334. "cn" => "China",
  335. "cx" => "Christmas Island",
  336. "cc" => "Cocos (Keeling) Islands",
  337. "co" => "Colombia",
  338. "km" => "Comoros",
  339. "cg" => "Congo",
  340. "cd" => "Congo, the Democratic Republic of the",
  341. "ck" => "Cook Islands",
  342. "cr" => "Costa Rica",
  343. "ci" => "Cote D'ivoire",
  344. "hr" => "Croatia",
  345. "cu" => "Cuba",
  346. "cy" => "Cyprus",
  347. "cz" => "Czech Republic",
  348. "dk" => "Denmark",
  349. "dj" => "Djibouti",
  350. "dm" => "Dominica",
  351. "do" => "Dominican Republic",
  352. "ec" => "Ecuador",
  353. "eg" => "Egypt",
  354. "sv" => "El Salvador",
  355. "gq" => "Equatorial Guinea",
  356. "er" => "Eritrea",
  357. "ee" => "Estonia",
  358. "et" => "Ethiopia",
  359. "fk" => "Falkland Islands (Malvinas)",
  360. "fo" => "Faroe Islands",
  361. "fj" => "Fiji",
  362. "fi" => "Finland",
  363. "fr" => "France",
  364. "gf" => "French Guiana",
  365. "pf" => "French Polynesia",
  366. "tf" => "French Southern Territories",
  367. "ga" => "Gabon",
  368. "gm" => "Gambia",
  369. "ge" => "Georgia",
  370. "de" => "Germany",
  371. "gh" => "Ghana",
  372. "gi" => "Gibraltar",
  373. "gr" => "Greece",
  374. "gl" => "Greenland",
  375. "gd" => "Grenada",
  376. "gp" => "Guadeloupe",
  377. "gu" => "Guam",
  378. "gt" => "Guatemala",
  379. "gn" => "Guinea",
  380. "gw" => "Guinea-Bissau",
  381. "gy" => "Guyana",
  382. "ht" => "Haiti",
  383. "hm" => "Heard Island and Mcdonald Islands",
  384. "va" => "Holy See (Vatican City State)",
  385. "hn" => "Honduras",
  386. "hk" => "Hong Kong",
  387. "hu" => "Hungary",
  388. "is" => "Iceland",
  389. "in" => "India",
  390. "id" => "Indonesia",
  391. "ir" => "Iran, Islamic Republic of",
  392. "iq" => "Iraq",
  393. "ie" => "Ireland",
  394. "il" => "Israel",
  395. "it" => "Italy",
  396. "jm" => "Jamaica",
  397. "jp" => "Japan",
  398. "jo" => "Jordan",
  399. "kz" => "Kazakhstan",
  400. "ke" => "Kenya",
  401. "ki" => "Kiribati",
  402. "kp" => "Korea, Democratic People's Republic of",
  403. "kr" => "Korea, Republic of",
  404. "kw" => "Kuwait",
  405. "kg" => "Kyrgyzstan",
  406. "la" => "Lao People's Democratic Republic",
  407. "lv" => "Latvia",
  408. "lb" => "Lebanon",
  409. "ls" => "Lesotho",
  410. "lr" => "Liberia",
  411. "ly" => "Libyan Arab Jamahiriya",
  412. "li" => "Liechtenstein",
  413. "lt" => "Lithuania",
  414. "lu" => "Luxembourg",
  415. "mo" => "Macao",
  416. "mk" => "Macedonia, the Former Yugosalv Republic of",
  417. "mg" => "Madagascar",
  418. "mw" => "Malawi",
  419. "my" => "Malaysia",
  420. "mv" => "Maldives",
  421. "ml" => "Mali",
  422. "mt" => "Malta",
  423. "mh" => "Marshall Islands",
  424. "mq" => "Martinique",
  425. "mr" => "Mauritania",
  426. "mu" => "Mauritius",
  427. "yt" => "Mayotte",
  428. "mx" => "Mexico",
  429. "fm" => "Micronesia, Federated States of",
  430. "md" => "Moldova, Republic of",
  431. "mc" => "Monaco",
  432. "mn" => "Mongolia",
  433. "ms" => "Montserrat",
  434. "ma" => "Morocco",
  435. "mz" => "Mozambique",
  436. "mm" => "Myanmar",
  437. "na" => "Namibia",
  438. "nr" => "Nauru",
  439. "np" => "Nepal",
  440. "nl" => "Netherlands",
  441. "an" => "Netherlands Antilles",
  442. "nc" => "New Caledonia",
  443. "nz" => "New Zealand",
  444. "ni" => "Nicaragua",
  445. "ne" => "Niger",
  446. "ng" => "Nigeria",
  447. "nu" => "Niue",
  448. "nf" => "Norfolk Island",
  449. "mp" => "Northern Mariana Islands",
  450. "no" => "Norway",
  451. "om" => "Oman",
  452. "pk" => "Pakistan",
  453. "pw" => "Palau",
  454. "ps" => "Palestinian Territory, Occupied",
  455. "pa" => "Panama",
  456. "pg" => "Papua New Guinea",
  457. "py" => "Paraguay",
  458. "pe" => "Peru",
  459. "ph" => "Philippines",
  460. "pn" => "Pitcairn",
  461. "pl" => "Poland",
  462. "pt" => "Portugal",
  463. "pr" => "Puerto Rico",
  464. "qa" => "Qatar",
  465. "re" => "Reunion",
  466. "ro" => "Romania",
  467. "ru" => "Russian Federation",
  468. "rw" => "Rwanda",
  469. "sh" => "Saint Helena",
  470. "kn" => "Saint Kitts and Nevis",
  471. "lc" => "Saint Lucia",
  472. "pm" => "Saint Pierre and Miquelon",
  473. "vc" => "Saint Vincent and the Grenadines",
  474. "ws" => "Samoa",
  475. "sm" => "San Marino",
  476. "st" => "Sao Tome and Principe",
  477. "sa" => "Saudi Arabia",
  478. "sn" => "Senegal",
  479. "cs" => "Serbia and Montenegro",
  480. "sc" => "Seychelles",
  481. "sl" => "Sierra Leone",
  482. "sg" => "Singapore",
  483. "sk" => "Slovakia",
  484. "si" => "Slovenia",
  485. "sb" => "Solomon Islands",
  486. "so" => "Somalia",
  487. "za" => "South Africa",
  488. "gs" => "South Georgia and the South Sandwich Islands",
  489. "es" => "Spain",
  490. "lk" => "Sri Lanka",
  491. "sd" => "Sudan",
  492. "sr" => "Suriname",
  493. "sj" => "Svalbard and Jan Mayen",
  494. "sz" => "Swaziland",
  495. "se" => "Sweden",
  496. "ch" => "Switzerland",
  497. "sy" => "Syrian Arab Republic",
  498. "tw" => "Taiwan, Province of China",
  499. "tj" => "Tajikistan",
  500. "tz" => "Tanzania, United Republic of",
  501. "th" => "Thailand",
  502. "tl" => "Timor-Leste",
  503. "tg" => "Togo",
  504. "tk" => "Tokelau",
  505. "to" => "Tonga",
  506. "tt" => "Trinidad and Tobago",
  507. "tn" => "Tunisia",
  508. "tr" => "Turkey",
  509. "tm" => "Turkmenistan",
  510. "tc" => "Turks and Caicos Islands",
  511. "tv" => "Tuvalu",
  512. "ug" => "Uganda",
  513. "ua" => "Ukraine",
  514. "ae" => "United Arab Emirates",
  515. "uk" => "United Kingdom",
  516. "us" => "United States",
  517. "um" => "United States Minor Outlying Islands",
  518. "uy" => "Uruguay",
  519. "uz" => "Uzbekistan",
  520. "vu" => "Vanuatu",
  521. "ve" => "Venezuela",
  522. "vn" => "Viet Nam",
  523. "vg" => "Virgin Islands, British",
  524. "vi" => "Virgin Islands, U.S.",
  525. "wf" => "Wallis and Futuna",
  526. "eh" => "Western Sahara",
  527. "ye" => "Yemen",
  528. "zm" => "Zambia",
  529. "zw" => "Zimbabwe"
  530. ]
  531. ],
  532. "nsfw" => [
  533. "display" => "NSFW",
  534. "option" => [
  535. "yes" => "Yes", // safe=active
  536. "no" => "No" // safe=off
  537. ]
  538. ],
  539. "lang" => [ // lr=<lang> (prefix lang with "lang_")
  540. "display" => "Language",
  541. "option" => [
  542. "any" => "Any language",
  543. "ar" => "Arabic",
  544. "bg" => "Bulgarian",
  545. "ca" => "Catalan",
  546. "cs" => "Czech",
  547. "da" => "Danish",
  548. "de" => "German",
  549. "el" => "Greek",
  550. "en" => "English",
  551. "es" => "Spanish",
  552. "et" => "Estonian",
  553. "fi" => "Finnish",
  554. "fr" => "French",
  555. "hr" => "Croatian",
  556. "hu" => "Hungarian",
  557. "id" => "Indonesian",
  558. "is" => "Icelandic",
  559. "it" => "Italian",
  560. "iw" => "Hebrew",
  561. "ja" => "Japanese",
  562. "ko" => "Korean",
  563. "lt" => "Lithuanian",
  564. "lv" => "Latvian",
  565. "nl" => "Dutch",
  566. "no" => "Norwegian",
  567. "pl" => "Polish",
  568. "pt" => "Portuguese",
  569. "ro" => "Romanian",
  570. "ru" => "Russian",
  571. "sk" => "Slovak",
  572. "sl" => "Slovenian",
  573. "sr" => "Serbian",
  574. "sv" => "Swedish",
  575. "tr" => "Turkish",
  576. "zh-CN" => "Chinese (Simplified)",
  577. "zh-TW" => "Chinese (Traditional)"
  578. ]
  579. ],
  580. "newer" => [ // &sort=review-date:r:20090301:20090430
  581. "display" => "Newer than",
  582. "option" => "_DATE"
  583. ],
  584. "older" => [
  585. "display" => "Older than",
  586. "option" => "_DATE"
  587. ],
  588. "size" => [ // tbs=isz:<size>
  589. "display" => "Size",
  590. "option" => [
  591. "any" => "Any size",
  592. "l" => "Large",
  593. "m" => "Medium",
  594. "i" => "Icon"
  595. ]
  596. ],
  597. "color" => [ // tbs=ic:<color>
  598. "display" => "Color",
  599. "option" => [
  600. "any" => "Any color",
  601. "gray" => "Black and white",
  602. "trans" => "Transparent",
  603. // from here, format is
  604. // tbs=specific,isc:<color>
  605. "red" => "Red",
  606. "orange" => "Orange",
  607. "yellow" => "Yellow",
  608. "green" => "Green",
  609. "teal" => "Teal",
  610. "blue" => "Blue",
  611. "purple" => "Purple",
  612. "pink" => "Pink",
  613. "white" => "White",
  614. "gray" => "Gray",
  615. "black" => "Black",
  616. "brown" => "Brown"
  617. ]
  618. ],
  619. "type" => [ // tbs=itp:<type>
  620. "display" => "Type",
  621. "option" => [
  622. "any" => "Any type",
  623. "clipart" => "Clip Art",
  624. "lineart" => "Line Drawing",
  625. "animated" => "GIF"
  626. ]
  627. ],
  628. "rights" => [ // tbs=il:<rights>
  629. "display" => "Usage rights",
  630. "option" => [
  631. "any" => "No license",
  632. "cl" => "Creative Commons licenses",
  633. "ol" => "Commercial & other licenses"
  634. ]
  635. ]
  636. ];
  637. break;
  638. }
  639. }
  640. private function get($url, $get = []){
  641. $headers = [
  642. "User-Agent: Mozilla/5.0 (Linux; U; Android 2.3.3; pt-pt; LG-P500h-parrot Build/GRI40) AppleWebKit/533.1 (KHTML, like Gecko) Version/4.0 Mobile Safari/533.1 MMS/LG-Android-MMS-V1.0/1.2",
  643. "Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,*/*;q=0.8",
  644. "Accept-Language: en-US,en;q=0.5",
  645. "Accept-Encoding: gzip",
  646. "DNT: 1",
  647. "Connection: keep-alive",
  648. "Upgrade-Insecure-Requests: 1",
  649. "Sec-Fetch-Dest: document",
  650. "Sec-Fetch-Mode: navigate",
  651. "Sec-Fetch-Site: none",
  652. "Sec-Fetch-User: ?1"
  653. ];
  654. $curlproc = curl_init();
  655. if($get !== []){
  656. $get = http_build_query($get);
  657. $url .= "?" . $get;
  658. }
  659. curl_setopt($curlproc, CURLOPT_URL, $url);
  660. curl_setopt($curlproc, CURLOPT_ENCODING, ""); // default encoding
  661. curl_setopt($curlproc, CURLOPT_HTTPHEADER, $headers);
  662. curl_setopt($curlproc, CURLOPT_RETURNTRANSFER, true);
  663. curl_setopt($curlproc, CURLOPT_SSL_VERIFYHOST, 2);
  664. curl_setopt($curlproc, CURLOPT_SSL_VERIFYPEER, true);
  665. curl_setopt($curlproc, CURLOPT_CONNECTTIMEOUT, 30);
  666. curl_setopt($curlproc, CURLOPT_TIMEOUT, 30);
  667. $data = curl_exec($curlproc);
  668. if(curl_errno($curlproc)){
  669. throw new Exception(curl_error($curlproc));
  670. }
  671. curl_close($curlproc);
  672. return $data;
  673. }
  674. public function web($get){
  675. $handle = fopen("scraper/google.html", "r");
  676. $html = fread($handle, filesize("scraper/google.html"));
  677. fclose($handle);
  678. $this->fuckhtml->load($html);
  679. $out = [
  680. "status" => "ok",
  681. "spelling" => [
  682. "type" => "no_correction",
  683. "using" => null,
  684. "correction" => null
  685. ],
  686. "npt" => null,
  687. "answer" => [],
  688. "web" => [],
  689. "image" => [],
  690. "video" => [],
  691. "news" => [],
  692. "related" => []
  693. ];
  694. $styles =
  695. $this->fuckhtml
  696. ->getElementsByTagName("style");
  697. $this->computedstyle = [];
  698. foreach($styles as $style){
  699. $this->computedstyle =
  700. array_merge(
  701. $this->computedstyle,
  702. $this->parsestyles($style["innerHTML"])
  703. );
  704. }
  705. // get images in javascript var
  706. preg_match(
  707. '/google\.ldi=({[^}]+})/',
  708. $html,
  709. $js_image
  710. );
  711. if(count($js_image) !== 0){
  712. $js_image = json_decode($js_image[1], true);
  713. }else{
  714. $js_image = [];
  715. }
  716. // get nodes
  717. // fuck you google!!!!!!!!!!!!!!
  718. $containers =
  719. $this->fuckhtml
  720. ->getElementsByClassName(
  721. $this->findstyles(
  722. [
  723. "background-color" => "#fff",
  724. "margin-bottom" => "10px",
  725. "-webkit-box-shadow" => "0 1px 6px rgba(32,33,36,0.28)",
  726. "border-radius" => "8px"
  727. ],
  728. self::is_class
  729. ),
  730. "div"
  731. );
  732. foreach($containers as $container){
  733. $this->fuckhtml->load($container);
  734. // get link at the top
  735. $link =
  736. $this->fuckhtml
  737. ->getElementsByTagName(
  738. "a"
  739. );
  740. if(count($link) !== 0){
  741. $link =
  742. $this->decodeurl(
  743. $link
  744. [0]
  745. ["attributes"]
  746. ["href"]
  747. );
  748. }
  749. /*
  750. Check for carousel presence
  751. */
  752. $carousel =
  753. $this->fuckhtml
  754. ->getElementsByClassName(
  755. "pcitem",
  756. "div"
  757. );
  758. $title =
  759. $this->fuckhtml
  760. ->getElementsByClassName(
  761. $this->findstyles(
  762. [
  763. "color" => "#1967d2",
  764. "font-size" => "20px",
  765. "line-height" => "26px"
  766. ],
  767. self::is_class
  768. ),
  769. "div"
  770. );
  771. $carousel_title =
  772. $this->fuckhtml
  773. ->getElementsByClassName(
  774. $this->findstyles(
  775. [
  776. "font-size" => "16px",
  777. "line-height" => "20px",
  778. "font-weight" => "400"
  779. ],
  780. self::is_class
  781. ),
  782. "div"
  783. );
  784. if(count($carousel) !== 0){
  785. $sublink = []; // twitter carousel sublinks
  786. foreach($carousel as $item){
  787. $this->fuckhtml->load($item);
  788. $url =
  789. $this->decodeurl(
  790. $this->fuckhtml
  791. ->getElementsByTagName(
  792. "a"
  793. )[0]
  794. ["attributes"]
  795. ["href"]
  796. );
  797. // detect if its a twitter carousel or
  798. // a list of news articles
  799. $grey_node =
  800. $this->fuckhtml
  801. ->getElementsByClassName(
  802. $this->findstyles(
  803. [
  804. "white-space" => "pre-line",
  805. "word-wrap" => "break-word"
  806. ],
  807. self::is_class
  808. ),
  809. "div"
  810. );
  811. if(count($carousel_title) !== 0){
  812. if(
  813. $this->fuckhtml
  814. ->getTextContent(
  815. $carousel_title[0]
  816. )
  817. == "Top stories"
  818. ){
  819. $img =
  820. $this->fuckhtml
  821. ->getElementsByTagName("img");
  822. if(
  823. count($img) !== 0 &&
  824. isset($img[0]["attributes"]["id"]) &&
  825. isset($js_image[$img[0]["attributes"]["id"]])
  826. ){
  827. $img = [
  828. "url" => $js_image[$img[0]["attributes"]["id"]],
  829. "ratio" => "16:9"
  830. ];
  831. }else{
  832. $img = [
  833. "url" => null,
  834. "ratio" => null
  835. ];
  836. }
  837. /*
  838. Is a news node
  839. */
  840. $out["news"][] = [
  841. "title" =>
  842. $this->fuckhtml
  843. ->getTextContent(
  844. $grey_node[0]
  845. ),
  846. "description" => null,
  847. "date" =>
  848. strtotime(
  849. explode(
  850. "\n",
  851. $grey_node[1]["innerHTML"]
  852. )[1]
  853. ),
  854. "thumb" => $img,
  855. "url" => $url
  856. ];
  857. }
  858. }else{
  859. /*
  860. Is a web node (twitter-like)
  861. create a link -> sublink structure and
  862. ignore images
  863. */
  864. switch(count($grey_node)){
  865. case 0:
  866. continue 2;
  867. case 1:
  868. $sublink_title = $grey_node[0];
  869. $sublink_description = null;
  870. break;
  871. case 2:
  872. $sublink_title = $grey_node[1];
  873. $sublink_description =
  874. $this->titledots(
  875. $this->fuckhtml
  876. ->getTextContent(
  877. $grey_node[0]
  878. )
  879. );
  880. break;
  881. }
  882. $sublink_url =
  883. $this->decodeurl(
  884. $this->fuckhtml
  885. ->getTextContent(
  886. $this->fuckhtml
  887. ->getElementsByTagName(
  888. "a"
  889. )[0]
  890. ["attributes"]
  891. ["href"]
  892. )
  893. );
  894. if($link == $sublink_url){
  895. continue;
  896. }
  897. $sublink_title =
  898. explode(
  899. " • ",
  900. $this->fuckhtml
  901. ->getTextContent(
  902. $sublink_title["innerHTML"]
  903. )
  904. );
  905. if(count($sublink_title) !== 1){
  906. $date = strtotime($sublink_title[1]);
  907. }else{
  908. $date = null;
  909. }
  910. $sublink_title = $this->titledots($sublink_title[0]);
  911. $sublink[] = [
  912. "title" => $sublink_title,
  913. "date" => $date,
  914. "description" => $sublink_description,
  915. "url" => $sublink_url
  916. ];
  917. }
  918. }
  919. // if it was a web node
  920. if(count($sublink) !== 0){
  921. $out["web"][] = [
  922. "title" =>
  923. $this->titledots(
  924. $this->fuckhtml
  925. ->getTextContent(
  926. $title[0]
  927. )
  928. ),
  929. "description" => null,
  930. "url" => $url,
  931. "date" => null,
  932. "type" => "web",
  933. "thumb" => [
  934. "url" => null,
  935. "ratio" => null
  936. ],
  937. "sublink" => $sublink,
  938. "table" => []
  939. ];
  940. }
  941. continue;
  942. }
  943. if(count($title) !== 0){
  944. /*
  945. Get WEB search results
  946. */
  947. $thumb =
  948. $this->fuckhtml
  949. ->getElementsByTagName("img");
  950. if(
  951. count($thumb) !== 0 &&
  952. isset($js_image[$thumb[0]["attributes"]["id"]])
  953. ){
  954. $thumb = [
  955. "url" =>
  956. $js_image[$thumb[0]["attributes"]["id"]],
  957. "ratio" => "1:1"
  958. ];
  959. }else{
  960. $thumb = [
  961. "url" => null,
  962. "ratio" => null
  963. ];
  964. }
  965. // this contains description, sublinks
  966. $inner_category =
  967. $this->fuckhtml
  968. ->getElementsByClassName(
  969. $this->findstyles(
  970. [
  971. "white-space" => "pre-line",
  972. "word-wrap" => "break-word"
  973. ],
  974. self::is_class
  975. ),
  976. "div"
  977. );
  978. // set empty values
  979. $description = null;
  980. $table = [];
  981. $sublinks = [];
  982. $date = null;
  983. foreach($inner_category as $category){
  984. if($category["level"] !== 6){
  985. // enterring protocol 6
  986. // and u dont seem to understaaaaandddddd
  987. continue;
  988. }
  989. $this->fuckhtml->load($category);
  990. // check if its a table
  991. preg_match(
  992. '/^[A-z0-9 ]+: <span/',
  993. $category["innerHTML"],
  994. $tablematch
  995. );
  996. if(count($tablematch) !== 0){
  997. $categories = explode("<br>", $category["innerHTML"]);
  998. foreach($categories as $cat){
  999. $cat = explode(":", $cat, 2);
  1000. $table[
  1001. $this->fuckhtml
  1002. ->getTextContent(
  1003. $cat[0]
  1004. )
  1005. ] =
  1006. $this->titledots(
  1007. $this->fuckhtml
  1008. ->getTextContent(
  1009. $cat[1]
  1010. )
  1011. );
  1012. }
  1013. continue;
  1014. }
  1015. $spans =
  1016. $this->fuckhtml
  1017. ->getElementsByTagName("span");
  1018. foreach($spans as $span){
  1019. // replace element with nothing
  1020. if(empty($description)){
  1021. $category["innerHTML"] =
  1022. str_replace(
  1023. $span["outerHTML"],
  1024. "",
  1025. $category["innerHTML"]
  1026. );
  1027. }
  1028. // get rating
  1029. if(isset($span["attributes"]["aria-hidden"])){
  1030. $table["Rating"] = $span["innerHTML"];
  1031. continue;
  1032. }
  1033. }
  1034. if(empty($description)){
  1035. $description =
  1036. $this->titledots(
  1037. $this->fuckhtml
  1038. ->getTextContent(
  1039. $category
  1040. )
  1041. );
  1042. }
  1043. }
  1044. // check if traversed div is the description
  1045. /*
  1046. if(
  1047. count(
  1048. $this->fuckhtml
  1049. ->getElementsByTagName("*")
  1050. ) === 0
  1051. ){
  1052. $description =
  1053. $this->fuckhtml
  1054. ->getTextContent($inner_category);
  1055. }else{
  1056. $this->
  1057. // we need to traverse description struct
  1058. foreach($inner_category as $category){
  1059. // detect description
  1060. $this->fuckhtml->load($category);
  1061. $spans =
  1062. $this->fuckhtml
  1063. ->getElementsByTagName("span");
  1064. $is_desc = false;
  1065. $is_first_span = true;
  1066. foreach($spans as $span){
  1067. // get rating
  1068. if(isset($span["attributes"]["aria-hidden"])){
  1069. $table["Rating"] = $span["innerHTML"] . "/5";
  1070. continue;
  1071. }
  1072. // get date posted
  1073. if(
  1074. $is_first_span &&
  1075. $date_tmp = strtotime($span["innerHTML"])
  1076. ){
  1077. $date = $date_tmp;
  1078. continue;
  1079. }
  1080. $is_first_span = false;
  1081. }
  1082. }
  1083. }*/
  1084. // get sublinks
  1085. $this->fuckhtml->load($container["innerHTML"]);
  1086. $as =
  1087. $this->fuckhtml->getElementsByTagName("a");
  1088. foreach($as as $a){
  1089. $this->fuckhtml->load($a);
  1090. $detect =
  1091. $this->fuckhtml
  1092. ->getElementsByClassName(
  1093. $this->findstyles(
  1094. [
  1095. "color" => "#1967d2",
  1096. "font-size" => "14px",
  1097. "line-height" => "20px"
  1098. ],
  1099. self::is_class
  1100. ),
  1101. "span"
  1102. );
  1103. if(count($detect) !== 0){
  1104. $sublinks[] = [
  1105. "title" =>
  1106. $this->titledots(
  1107. $this->fuckhtml
  1108. ->getTextContent(
  1109. $a
  1110. )
  1111. ),
  1112. "date" => null,
  1113. "description" => null,
  1114. "url" =>
  1115. $this->decodeurl(
  1116. $a["attributes"]["href"]
  1117. )
  1118. ];
  1119. }
  1120. }
  1121. $data = [
  1122. "title" =>
  1123. $this->titledots(
  1124. $this->fuckhtml
  1125. ->getTextContent(
  1126. $title[0]
  1127. )
  1128. ),
  1129. "description" => $description,
  1130. "url" => $link,
  1131. "date" => $date,
  1132. "type" => "web",
  1133. "thumb" => $thumb,
  1134. "sublink" => $sublinks,
  1135. "table" => $table
  1136. ];
  1137. $out["web"][] = $data;
  1138. continue;
  1139. }
  1140. /*
  1141. Check related searches node
  1142. */
  1143. $relateds =
  1144. $this->fuckhtml
  1145. ->getElementsByClassName(
  1146. $this->findstyles(
  1147. [
  1148. "display" => "block",
  1149. "position" => "relative",
  1150. "width" => "100%"
  1151. ],
  1152. self::is_class
  1153. ),
  1154. "a"
  1155. );
  1156. if(count($relateds) !== 0){
  1157. foreach($relateds as $related){
  1158. $out["related"][] =
  1159. $this->fuckhtml
  1160. ->getTextContent(
  1161. $related
  1162. );
  1163. }
  1164. }
  1165. /*
  1166. Get next page
  1167. */
  1168. $nextpage =
  1169. $this->fuckhtml
  1170. ->getElementsByClassName(
  1171. $this->findstyles(
  1172. [
  1173. "-webkit-box-flex" => "1",
  1174. "display" => "block"
  1175. ],
  1176. self::is_class
  1177. ),
  1178. "a"
  1179. );
  1180. if(count($nextpage) !== 0){
  1181. $out["npt"] =
  1182. explode(
  1183. "?",
  1184. $this->fuckhtml
  1185. ->getTextContent(
  1186. $nextpage[0]
  1187. ["attributes"]
  1188. ["href"]
  1189. )
  1190. )[1];
  1191. }
  1192. }
  1193. return $out;
  1194. }
  1195. public function image($get){
  1196. $handle = fopen("scraper/google-img.html", "r");
  1197. $html = fread($handle, filesize("scraper/google-img.html"));
  1198. fclose($handle);
  1199. $this->fuckhtml->load($html);
  1200. $out = [
  1201. "status" => "ok",
  1202. "npt" => null,
  1203. "image" => []
  1204. ];
  1205. $images =
  1206. $this->fuckhtml
  1207. ->getElementsByClassName(
  1208. "islrtb isv-r",
  1209. "div"
  1210. );
  1211. // get next page
  1212. // https://www.google.com/search
  1213. // ?q=higurashi
  1214. // &tbm=isch
  1215. // &async=_id%3Aislrg_c%2C_fmt%3Ahtml
  1216. // &asearch=ichunklite
  1217. // &ved=0ahUKEwidjYXJqJSAAxWrElkFHZ07CDwQtDIIQygA
  1218. $ved =
  1219. $this->fuckhtml
  1220. ->getElementById("islrg", "div");
  1221. if($ved){
  1222. $ved =
  1223. $this->fuckhtml
  1224. ->getTextContent(
  1225. $ved["attributes"]["data-ved"]
  1226. );
  1227. // &vet=1{$ved}..i (10ahUKEwidjYXJqJSAAxWrElkFHZ07CDwQtDIIQygA..i)
  1228. /*
  1229. These 2 are handled by us
  1230. start = start + number of results
  1231. ijn = current page number
  1232. */
  1233. // &start=100
  1234. // &ijn=1
  1235. // &imgvl=CAEY7gQgBSj3Aji8VTjXVUC4AUC3AUgAYNdV
  1236. preg_match(
  1237. '/var e=\'([A-z0-9]+)\';/',
  1238. $html,
  1239. $imgvl
  1240. );
  1241. $imgvl = $imgvl[1];
  1242. $out["npt"] = [
  1243. "q" => $get["s"],
  1244. "tbm" => "isch",
  1245. "async" => "_id:islrg_c,_fmt:html",
  1246. "asearch" => "ichunklite",
  1247. "ved" => $ved,
  1248. "vet" => "1" . $ved . "..i",
  1249. "start" => 100,
  1250. "ijn" => 1,
  1251. "imgvl" => $imgvl
  1252. ];
  1253. }
  1254. foreach($images as $image){
  1255. $this->fuckhtml->load($image);
  1256. $img =
  1257. $this->fuckhtml
  1258. ->getElementsByTagName("img")[0];
  1259. $og_width = (int)$image["attributes"]["data-ow"];
  1260. $og_height = (int)$image["attributes"]["data-oh"];
  1261. $thumb_width = (int)$image["attributes"]["data-tw"];
  1262. $ratio = $og_width / $og_height;
  1263. if(isset($img["attributes"]["data-src"])){
  1264. $src = &$img["attributes"]["data-src"];
  1265. }else{
  1266. $src = &$img["attributes"]["src"];
  1267. }
  1268. $thumb_height = floor($thumb_width / $ratio);
  1269. $out["image"][] = [
  1270. "title" =>
  1271. $this->titledots(
  1272. $this->fuckhtml
  1273. ->getTextContent(
  1274. $image["attributes"]["data-pt"]
  1275. )
  1276. ),
  1277. "source" => [
  1278. [
  1279. "url" =>
  1280. $this->fuckhtml
  1281. ->getTextContent(
  1282. $image["attributes"]["data-ou"]
  1283. ),
  1284. "width" => $og_width,
  1285. "height" => $og_height
  1286. ],
  1287. [
  1288. "url" =>
  1289. $this->fuckhtml
  1290. ->getTextContent(
  1291. $src
  1292. ),
  1293. "width" => $thumb_width,
  1294. "height" => $thumb_height
  1295. ]
  1296. ],
  1297. "url" =>
  1298. $this->fuckhtml
  1299. ->getTextContent(
  1300. $image["attributes"]["data-ru"]
  1301. )
  1302. ];
  1303. }
  1304. return $out;
  1305. }
  1306. private function findstyles($rules, $is){
  1307. ksort($rules);
  1308. foreach($this->computedstyle as $stylename => $styles){
  1309. if($styles == $rules){
  1310. preg_match(
  1311. '/\\' . $is . '([^ .]+)/',
  1312. $stylename,
  1313. $out
  1314. );
  1315. if(count($out) === 2){
  1316. return $out[1];
  1317. }
  1318. return false;
  1319. }
  1320. }
  1321. return false;
  1322. }
  1323. private function parsestyles($style){
  1324. // get style tags
  1325. preg_match_all(
  1326. '/([^{]+){([^}]+)}/',
  1327. $style,
  1328. $tags_regex
  1329. );
  1330. $tags = [];
  1331. for($i=0; $i<count($tags_regex[0]); $i++){
  1332. $tagnames = explode(",", trim($tags_regex[1][$i]));
  1333. foreach($tagnames as $tagname){
  1334. $tagname = trim($tagname);
  1335. if(!isset($tags[$tagname])){
  1336. $tags[$tagname] = [];
  1337. }
  1338. $values = explode(";", $tags_regex[2][$i]);
  1339. foreach($values as $value){
  1340. $value = explode(":", $value, 2);
  1341. if(count($value) !== 2){
  1342. continue;
  1343. }
  1344. $tags[$tagname][trim($value[0])] =
  1345. trim($value[1]);
  1346. }
  1347. }
  1348. }
  1349. foreach($tags as &$value){
  1350. ksort($value);
  1351. }
  1352. return $tags;
  1353. }
  1354. private function decodeurl($url){
  1355. preg_match(
  1356. '/^\/url\?q=([^&]+)|^\/interstitial\?url=([^&]+)/',
  1357. $this->fuckhtml
  1358. ->getTextContent($url),
  1359. $match
  1360. );
  1361. if(count($match) !== 0){
  1362. if(!empty($match[1])){
  1363. return urldecode($match[1]);
  1364. }
  1365. if(!empty($match[2])){
  1366. return urldecode($match[2]);
  1367. }
  1368. }
  1369. return null;
  1370. }
  1371. private function titledots($title){
  1372. return rtrim($title, ".… \t\n\r\0\x0B");
  1373. }
  1374. }