import requests
from bs4 import BeautifulSoup
from urllib import request
headers = {
'user-agent': 'Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.25 Safari/537.36 Core/1.70.3877.400 QQBrowser/10.8.4507.400'
}
for i in range(3):
Furl = 'http://stockpage.10jqka.com.cn/'
allrul = ['600511', '600512', '600513', '600515']
url = Furl + allrul[i]
print(url)
req = request.Request(url=url, headers=headers)
rsp = request.urlopen(req)
html = rsp.read().decode('utf-8')
bf = BeautifulSoup(html, "html.parser")
texts = bf.find_all('dl', class_='company_details')
str_Result = str(texts)
splitR = str_Result.splitlines()
print(splitR)
print(len(splitR))
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24