tiger吴 发表于 2020-7-3 23:16:19

关于爬虫

import requests
url="http://placekitten.com/400/800"
headers = {
      'User-Agent':'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/65.0.3314.0 Safari/537.36 SE 2.X MetaSr 1.0',
      'referer':url2      
      }
responce=requests.get(url,headers)
with open("C:\Users\Lenovo\Desktop\hellow.py","wb") as f:
    f.write(responce.content)

求解?

Twilight6 发表于 2020-7-3 23:18:57



这样试试看,在路径那加上 r

import requests
url="http://placekitten.com/400/800"
headers = {
      'User-Agent':'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/65.0.3314.0 Safari/537.36 SE 2.X MetaSr 1.0',
      'referer':url   
      }
responce=requests.get(url,headers)
with open(r"C:\Users\Lenovo\Desktop\hellow.py","wb") as f:
    f.write(responce.content)
页: [1]
查看完整版本: 关于爬虫