python爬虫
小兔崽崽!
我还年轻!!!
展开
-
爬取贴吧图片(lisa吧)
import requests import parsel base_url = "https://tieba.baidu.com/f?kw=%E7%BE%8E%E5%A5%B3&ie=utf-8" headers = {'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; WOW64; Trident/7.0; rv:11.0) like Gecko'...原创 2020-04-24 11:20:12 · 398 阅读 · 0 评论 -
实战:最好大学排名
import requests from bs4 import BeautifulSoup import bs4 def getHTMLText(url): try: r = requests.get(url, timeout=30) r.raise_for_status() r.encoding = r.apparent_encodin...原创 2020-03-29 22:32:26 · 79 阅读 · 0 评论 -
BeautifulSoup类
原创 2020-03-29 22:32:12 · 73 阅读 · 0 评论 -
实战:图片爬取
import requests import os url = "http://img0.dili360.com/pic/2019/12/31/5e0b0f6435f2f0886220573.jpg" root = "D://pics//" path = root + url.split('/')[-1] try: if not os.path.exists(root): ...原创 2020-03-29 22:35:07 · 348 阅读 · 0 评论 -
实战:爬亚马逊网站商品实例以及用关键词爬搜索引擎
对网络爬虫有两种限制 1.robot协议告知哪些是可以访问的,哪些是不可以访问的。 2.通过对访问网站的http的头来查看你的访问是不是由一个爬虫引起的,进而拒绝你的访问。 用 headers 字段通过程序模拟一个浏览器去访问网站。 import requests url = " https://www.amazon.cn/dp/B01JRE0HKW/ref=tmm_kin_title_sr?_e...原创 2020-03-29 22:35:00 · 612 阅读 · 0 评论 -
爬取网页的通用代码框架
import requests def getHTMLText(url): try: r = requests.get(url,timeout = 30) r.raise_for_status()#如果状态不是200,将引发HTTPEorro异常 r.encoding = r.apparent_encoding retur...原创 2020-03-29 22:31:24 · 131 阅读 · 0 评论