.DokiDoki

导航

python 爬虫goole主页

import requests
url="https://www.google.cn/"
def gethtml(url):
    try:
        r=requests.get(url)
        r.raise_for_status()
        r.encoding="utf-8"
        print("text内容:",r.text)
    except:
        return "Error!"
for i in range(20):
    print(gethtml(url))

运行结果:

posted on 2020-12-14 19:13  .DokiDoki  阅读(86)  评论(0编辑  收藏  举报