摘要: url = "https:" + url 或者url = response.urljoin(url) #这里代表的是自动补全url 阅读全文
posted @ 2019-03-14 13:38 乔儿 阅读(689) 评论(0) 推荐(0) 编辑
摘要: 1.通过肉眼识别,然后输入到input里面 from PIL import image Image request.urlretrieve(url,'image') #下载验证码图片 image = Image.open('image') #程序内部打开图片 image.show() #将图片显示出 阅读全文
posted @ 2019-03-14 10:42 乔儿 阅读(552) 评论(0) 推荐(0) 编辑
摘要: import os #创建文件夹 from urllib import request #下载图片 if not os.path.exists('文件夹名字'): #创建文件夹名字 os.mkdir('文件夹名字') img_path = '文件夹名字/' + 图片名字 request.urlretrieve(url=url,filename=img_path) #u... 阅读全文
posted @ 2019-03-14 09:12 乔儿 阅读(984) 评论(0) 推荐(0) 编辑
摘要: 标签如下:<img id="captcha_image" src="https://www.douban.com/misc/cantcha?id=jskdjf" alt="captcha" class="captcha_image"> 使用css选择器:captcha_img = html.css( 阅读全文
posted @ 2019-03-14 09:09 乔儿 阅读(95) 评论(0) 推荐(0) 编辑
摘要: 注:scrapy框架默认发送get请求 1. scrapy.FormRequest(url,formdata=data,callback=self.parse_page) 2. scrapy.Request(url=url, cookies=self.cookie, headers=self.hea 阅读全文
posted @ 2019-03-13 22:34 乔儿 阅读(527) 评论(0) 推荐(0) 编辑
摘要: 1.可以方便我们做一些数据提取的测试代码; 2.如果想要执行scrapy命令,那么毫无疑问,肯定是要先进入到scrapy所在的环境中; 3.如果想要读取某个项目的配置信息,那么应该先进入到这个项目中。再执行scrapy shell + url 命令。 阅读全文
posted @ 2019-03-13 20:16 乔儿 阅读(210) 评论(0) 推荐(0) 编辑
摘要: 1.allow设置规则的方法:要能够限制在我们想要的url上面。不要跟其他的url产生相同的正则表达式即可; 2.什么情况下使用follow:如果在爬取页面的时候,需要将满足当前条件的url再进行跟进,那么就设置为True。否则设置为False; 3.什么情况下该指定callback:如果这个url 阅读全文
posted @ 2019-03-13 18:28 乔儿 阅读(415) 评论(0) 推荐(0) 编辑
摘要: "".join(列表) 的作用是将列表中的元素拿出来组成一个语句。比如图片一,但是列表中的数据必须得是str,int类型不行,如果是数字,可以用“int”来代表。 阅读全文
posted @ 2019-03-12 23:55 乔儿 阅读(149) 评论(0) 推荐(0) 编辑
摘要: 阅读全文
posted @ 2019-03-12 23:46 乔儿 阅读(143) 评论(0) 推荐(0) 编辑
摘要: 1、用正则表达式将空格去掉:re.sub(r"\s","",str) #\s表示空白字符,""表示要替换成的空白字符,str表示一个语句。 2、 阅读全文
posted @ 2019-03-10 17:28 乔儿 阅读(1212) 评论(0) 推荐(0) 编辑