爬虫入门程序

import requests
url=input("请输入你想爬取的网页:")
try:
    r=requests.get(url)
    r.raise_for_status()
    r.encoding=r.apparent_encoding
    print(r.text)
    'print(r.text[:1000])'#限制爬取内容长度
except:
    print("爬取失败")

猜你喜欢

转载自blog.csdn.net/qq_38452951/article/details/109283159
今日推荐