|
@@ -7,7 +7,7 @@ class APILink():
|
|
|
#打开链接,返回title
|
|
|
def obtain_url_title(self,url):
|
|
|
response = requests.get(url,headers = {
|
|
|
- 'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.124 Safari/537.36'})
|
|
|
+ 'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.124 Safari/537.36;jy-test'})
|
|
|
response.encoding = 'utf-8' # 设置编码为utf-8
|
|
|
soup = BeautifulSoup(response.text, 'html.parser')
|
|
|
title = soup.title.string
|
|
@@ -16,7 +16,7 @@ class APILink():
|
|
|
#打开链接,status=200,返回true
|
|
|
def open_url_status(self,url):
|
|
|
response = requests.get(url,headers = {
|
|
|
- 'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.124 Safari/537.36'})
|
|
|
+ 'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.124 Safari/537.36;jy-test'})
|
|
|
status_code = response.status_code
|
|
|
if status_code==200:
|
|
|
return True
|