FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

针对反爬虫,进行了修改,添加referer · David20111030/python-spider@18ff01c · GitHub

Repository navigation

Commit 18ff01c

Browse files
committed
针对反爬虫,进行了修改,添加referer
1 parent cfafee1 commit 18ff01c

1 file changed

Lines changed: 3 additions & 2 deletions

File tree

‎one_hour_spider/vidoe_downloader.py‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ def __init__(self, url):
99
self.api = 'http://api.xfsub.com/xfsub_api/?url='
1010
self.get_url_api = 'http://api.xfsub.com/xfsub_api/url.php'
1111
self.url = url.split('#')[0]
12+
self.headers = {'Referer': 'http://api.xfsub.com/xfsub_api/?url=%s?qqdrsign=055a4' % self.url}
1213
self.target = self.api + self.url
1314
self.s = requests.session()
1415

@@ -40,9 +41,9 @@ def get_url(self):
4041
'key':self.info['key'],
4142
'url':self.info['url'],
4243
'type':''}
43-
req = self.s.post(url=self.get_url_api,data=data)
44+
req = self.s.post(url=self.get_url_api,data=data, headers=self.headers)
4445
url = self.server + json.loads(req.text)['url']
45-
req = self.s.get(url)
46+
req = self.s.get(url=url, headers=self.headers)
4647
bf = BeautifulSoup(req.text,'xml') #因为文件是xml格式的,所以要进行xml解析。
4748
video_url = bf.find('file').string #匹配到视频地址
4849
return video_url

0 commit comments

Comments
 (0)

Back | FazBrowse Home | New Git URL