day94_11_26爬虫find与findall
一。使用json 正常的,如果需要将response结果序列化,需要将结果json.loads res1=json.loads(response.text) 但是这样会很麻烦,request提供了json方法: res2=response.json() #直接获取json数据 二。SSL认证 ssl就是http+SSL,也就是https。需要带上证书才能访问特定的网站。 证书需要浏览器下载。 #SSL # https=http+ssl import requests respone=requests.get('https://www.12306.cn', cert=('/path/server.crt', '/path/key')) print(respone.status_code) 三。使用代理 在get请求中proxies关键字就是存放代理网址,:(西刺) 通过META.get('REMOVE_ADDR') import reques1ts proxies={ 'http':'http://egon:123@localhost:9743',#带用户名密码的代理,@符号前是用户名与密码 'http':'http://localhost:9743', 'https':'https://localhost:9743', 'http':'http:/