用代理IP进行简单的爬虫——爬高匿代理网站
发布日期:2021-08-14 08:22:15 浏览次数:6 分类:技术文章

本文共 817 字,大约阅读时间需要 2 分钟。

用西刺代理网站的IP爬高匿代理网站

1 import re 2 import _thread 3 from time import sleep,ctime 4 from urllib.request import urlopen 5 from urllib.request import Request 6 from urllib.request import ProxyHandler 7 from urllib.request import build_opener 8 from lxml import etree 9 10 url = "http://www.kuaidaili.com/free/"11 #设置代理IP12 proxy = {
'http':'113.123.13.149:808'}13 proxy_support = ProxyHandler(proxy)14 opener = build_opener(proxy_support)15 #设置访问协议头16 opener.addheaders = [('User-agent','Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.1.6) Gecko/20091201 Firefox/3.5.6')]17 r = opener.open(url)18 html = r.read().decode('utf-8')19 print(html)20 selector = etree.HTML(html)21 links = selector.xpath('//tr/td/text()')22 for link in links:23 print(link)

 

转载于:https://www.cnblogs.com/wangyuhangboke/p/7800811.html

转载地址:https://blog.csdn.net/weixin_30715523/article/details/96275674 如侵犯您的版权,请留言回复原文章的地址,我们会给您删除此文章,给您带来不便请您谅解!

上一篇:BZOJ 1009 :[HNOI2008]GT考试(KPM算法+dp+矩阵快速幂)
下一篇:ASP.NET MVC 学习第三天

发表评论

最新留言

能坚持,总会有不一样的收获!
[***.219.124.196]2024年04月06日 12时49分02秒

关于作者

    喝酒易醉,品茶养心,人生如梦,品茶悟道,何以解忧?唯有杜康!
-- 愿君每日到此一游!

推荐文章