运维辞典@欢迎访问小站,如有疑问,可通过右侧QQ或底部邮箱联系,非常感谢@

python爬虫之requests模块

Python Administrator 278℃

Requests 唯一的一个非转基因的 Python HTTP 库,人类可以安全享用。
http://docs.python-requests.org/zh_CN/latest/user/quickstart.html

import requests
from bs4 import BeautifulSoup

url = "http://note.724001.com/"
headers = {'User-Agent':'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/64.0.3282.140 Safari/537.36'}
res = requests.get(url,headers=headers)

res.encoding = 'utf-8'
soup = BeautifulSoup(res.text)
urls = soup.select("a")
for url in urls:
    print(url)

码字很辛苦,转载请注明来自:《运维辞典 » python爬虫之requests模块

喜欢 (0)