爬虫代码:
#coding:utf-8
import requests, json, random, time
from bs4 import BeautifulSoup
def dig(drugbank_accession_number="DB00460"):
url = "https://go.drugbank.com/drugs/" + drugbank_accession_number
# url = "https://en.wikipedia.org/wiki/Verteporfin"
headers = {
"User-Agent": "User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.3"
}
# 代理IP池
proxies = {
"http": "http://127.0.0.1:7890",
"https": "http://127.0.0.1:7890",
}
# proxy = random.choice(proxy_pool) # 随机选择代理IP
# # 发送请求获取响应
response = requests.get(url, headers=headers, proxies=proxies)
# print(response.text)
soup = BeautifulSoup(response.content, 'html.parser')
# soup = BeautifulSoup(hhhh(), 'html.parser')
#