import urllib.request,os,random,re,time
#pygain--翻版必究
def url_open(url):
req=urllib.request.Request(url)
req.add_header('User-Agent','Mozilla/5.0 (Windows NT 6.1; WOW64; rv:49.0) Gecko/20100101 Firefox/49.0')
# proxies=['27.210.129.153:81']
# proxy=random.choice(proxies)
# proxy_support=urllib.request.ProxyHandler({'http':proxy})
# opener=urllib.request.build_opener()
# urllib.request.install_opener(opener)
response=urllib.request.urlopen(req)
html=response.read()
return html
def get_page(url):
html=url_open(url).decode('gb18030')
# html=url_open(url)
url_page=re.findall(r'url=http://m\.mm131\.com/xinggan/.*?html',html)
aa=re.findall(r'[_]\d{0,2}',url_page[0])
print(aa)
bb=aa[0].split('_')[-1]
print(bb)
return bb
def find_imgs(url,folder):
html=url_open(url).decode('gb18030')
# html=url_open(
玩玩python之两个猥琐的爬虫
最新推荐文章于 2022-07-31 12:43:30 发布
本文记录了作者学习Python基础后,跟随教程编写了两个爬虫项目:一是抓取补天平台上的厂商列表,二是下载特定类型的图片。通过这两个实践,展示了Python在爬虫领域的应用。
摘要由CSDN通过智能技术生成