玩玩python之两个猥琐的爬虫

本文记录了作者学习Python基础后,跟随教程编写了两个爬虫项目:一是抓取补天平台上的厂商列表,二是下载特定类型的图片。通过这两个实践,展示了Python在爬虫领域的应用。
摘要由CSDN通过智能技术生成

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(
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值