php屏幕抓取问题 [英] screen scraping in php problem

查看:40
本文介绍了php屏幕抓取问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我制作了一个屏幕抓取模块,它工作得很好,但有一定的限制.现在我想删除这些边界,但我得到了如此不可预测和不同的错误.在你想到任何事情之前,让我看看实际上正在发生.最初,我使用屏幕抓取来检索一组关键字(搜索内容)的结果,谷歌的所有搜索引擎如 co.in/co.uk/nl/de/com.

i had made a screen scraping module which works very fine but with certain limitations.now i want to remove those boundations,but i got so unpredictable and different error. Before anything goes in ur mind let me wat is actually hapening. Initially i used screen scraping to retrieve result for a set of keyword(search content) google's all search engine like co.in/co.uk/nl/de/com.

但现在我不得不在一个循环中抓取多个搜索引擎和多个关键字的逻辑.

But now i had to scrape the logic for multiple search engine and multiple keywords in a loop.

让我们通过一个例子来看看这个:

Lets check out this with an example:

keyword     se            company         rank
telephony google.co.in    airtel          01
telephony google.co.in    bsnl            04
telephony google.co.in    aircel          06
telephony google.co.in    idea            03
mobile op google.co.uk    airtel          09
mobile op google.co.uk    bsnl            04

等等..超过 6 个关键字和所有显示的搜索引擎以及所有公司.

and so.. for more than 6 keywords and all shown search engines and for all company.

最初我是为一个关键字、se 和所有公司检索它.但现在我必须列出所有关键字、se、公司.只是我使用循环来做到这一点.但我遇到了这些错误:

Initially i was retreiving it for one keyword,se and all company.but now i have to make a list of all keywords,se,company. Simply i used loops to do that.But i faced these errors:

  1. 分配的内存 343322111 字节溢出(...[为了删除这个,我使用了 ini_set('memory') func]
  2. 求和后谷歌使用了验证码.要删除验证码,我使用了 sleep 或 usleep() 但它不能解决目的.atlast 错误:连接重置.我不能在 usleep func 中使用 30 秒或更长时间.检索信息需要几个小时.我的 5 页 google 代码搜索数据,这意味着使用 simple_html_dom.php
  3. 的 50responses.Lib
  1. memory allocated 343322111 bytes overflowed(...[to remove this i used ini_set('memory') func]
  2. after sum request google used capcha. To remove capcha i used sleep, or usleep() but it not solving purpose.atlast ERROR: connection reset. I cant use 30sec or more in usleep func.it will take hours to retreive info.My code search data for 5pages of google, that means 50responses.Lib using simple_html_dom.php

它适用于 1 页页面,但不适用于超过 3 页.我应该做什么/使用什么?

It works fine for 1page page but not for greater than 3pages.What should i do/use??

推荐答案

sleep() 函数和 &num=100 在查询中解决了这个问题.使用 &num=100 减少了对 google 的请求次数 10 次.在每个请求之间,我使用了 5 秒延迟,谷歌似乎是一个有效的、真实的、人工请求.

sleep() function with &num=100 in query solves the problem. Using &num=100 reduces the number of request to google 10times. and between every request i used 5 sec delay which google seems to be a valid,genuine,human request.

这篇关于php屏幕抓取问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆