爬取网页的通用框架

  ```

导包

import requests

自定义函数:获取网页

def getHtml():
try:
r = requests.get(url=url,headers=headers,timeout=20)
r.raise_for_status()
r.encoding=r.apparent_encoding
return r.text
except:
return "shibai"

你可能感兴趣的:(爬取网页的通用框架)