源码:
import requests
from my_fake_useragent import UserAgent as AA
import re
class Spider:
def __init__(self):
self.headers = {
'User_Agent': AA().random(),
'Cookie': 'portalCookie=BnCNQaPTLQ0SHoB2ahcMwWNwaWJUEFi2IT5DBSC9zLq_DHQqxBDY!2137240864; camcCookie=153093386.23067.0000; _pk_id.4.0e89=1344e365ac9c2ada.1617277621.1.1617277621.1617277621.; _pk_ses.4.0e89=*',
'Host': 'fund.chinaamc.com'
}
pass
def gethtml(self):
base_url = 'http://fund.chinaamc.com/portal/cn/include/newproducthome.jsp'
response = requests.get(url=base_url, headers=self.headers)
html = response.content.decode('gbk')
c = '<td .*?><a .*?title=".*?">(.*?)</a></td>\s+<td height="30">(.*?)</td>\s+<td height="30">(.*?)</td>\s+<td height="30">(.*?)</td>\s+<td height="30">(.*?)</td>\s+<td height="30">(.*?)</td>\s+<td height="30">(.*?)</td>\s+<td height="30">(.*?)</td>\s+<td height="30">(.*?)</td>\s+<td height="30">(.*?)</td>'
total = re.findall(c, html)
for all in total:
print(all)
if __name__ == '__main__':
cc = Spider().gethtml()