为什么我爬不出东西呢
各位HXD求助!!!这是小甲鱼老师2017年房价工资比排行那一个视频
import requests
def open_url(url):
headers = {"user-agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/85.0.4183.121 Safari/537.36",
"cookie": "RK=29q9G5zHYY; ptcz=a4381ec6e1d1693c7f5943672c54e1deb2db4518fd62063c95b1dbbc292ad9ef; pgv_pvid=5560979159; pgv_pvi=5043132416; h_uid=h592479673092227786; ptui_loginuin=1452796154; uin=o1452796154; skey=@ozFeZvD99; pac_uid=1_1452796154; iip=0; pgv_info=ssid=s9761391880; o_cookie=1452796154; ts_last=news.house.qq.com/a/20170702/003985.htm; ts_uid=2926725548"}
res = requests.get(url, headers=headers)
return res
def main():
url = "https://news.house.qq.com/a/20170702/003985.htm"
res = open_url(url)
with open("test.txt","w", encoding = "utf-8") as file:
file.write(res.text)
if __name__ == "__main __":
main()
为什么我运行之后没有出现test.txt文件呢 if __name__ == "__main __":
这一句代码main和下横杠中间多了一个空格。
页:
[1]