import requests r = requests.get('https://xueqiu.com/stock/forchartk/stocklist.json?symbol=SH600423&period=1day&type=before&end=1463365186825&_=1463365186825') print r.text
为啥会报 403 Forbidden. Your IP Address: .
应该怎么正确使用能得到返回结果?
小伙看你根骨奇佳,潜力无限,来学PHP伐。
You need to visit the main page to get the cookie first, and then operate
import requests session = requests.Session() session.headers = {'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/50.0.2661.102 Safari/537.36'} session.get('https://xueqiu.com/') r = session.get('https://xueqiu.com/stock/forchartk/stocklist.json?symbol=SH600423&period=1day&type=before&end=1463365186825&_=1463365186825') print r.text
Visually I guess you’re not logged in
Try adding user agent. It is also possible that the crawling frequency is too fast and the IP is blocked.
You need to visit the main page to get the cookie first, and then operate
Visually I guess you’re not logged in
Try adding user agent. It is also possible that the crawling frequency is too fast and the IP is blocked.