資源簡介
可以設置的ip數量爬取
運行前需要安裝 bs4模塊 以及 requests模塊
下載地址分別為:
https://pypi.python.org/packages/10/ed/7e8b97591f6f456174139ec089c769f89a94a1a4025fe967691de971f314/bs4-0.0.1.tar.gz
https://pypi.python.org/packages/16/09/37b69de7c924d318e51ece1c4ceb679bf93be9d05973bb30c35babd596e2/requests-2.13.0.tar.gz#md5=921ec6b48f2ddafc8bb6160957baf444
下載后安裝方法如下(以bs4模塊為例):
1.解壓bs4-0.0.1.tar.gz文件后,并 在命令行 cd到該目錄,輸入命令: python setup.py install
2. 回車運行,安裝完畢
代碼片段和文件信息
import?re
from?random?import?choice
import?requests
import?bs4
url?=?“http://www.xicidaili.com/“
headers?=?{?“Accept“:“text/htmlapplication/xhtml+xmlapplication/xml;“
“Accept-Encoding“:“gzip“
“Accept-Language“:“zh-CNzh;q=0.8“
“Referer“:“http://www.xicidaili.com/“
“User-Agent“:“Mozilla/5.0?(Windows?NT?6.1;?WOW64)?AppleWebKit/537.36?(KHTML?like?Gecko)?Chrome/42.0.2311.90?Safari/537.36“
}
r?=?requests.get(urlheaders=headers)
soup?=?bs4.BeautifulSoup(
- 上一篇:python3爬蟲采集淘寶商品數據
- 下一篇:python 爬蟲(pyspider)
評論
共有 條評論