我的WebScrapper使用 urllib 从YouTube等网站获取数据。但是,当请求太多时,我经常遇到问题,导致网站阻止我的连接。 所以我的问题是,在Python中有没有办法绕过这个? 例如更改IP地址(通过一些本机Socket模块,或 os.system ("某些命令,如netsh"),一个简单的 API #39; t需要身份验证(如oAuth或密钥),还是仅使用基于Web的代理来转移我的流量?
search_url = "https://www.youtube.com/results?search_query=" #Search URL
bypass_url = "https://someProxy.com/url=" + search_url
for video_ID in raw_video_list:
raw_html = self.ReadHTML( search_url + video_ID ) #Returns raw HTML
# Then the program does it's magic with that html
这只是该程序的一个基本概念,但它会像这样迭代一百多次。
使用Python 2.7,Windows 8,本机模块