代码拉取完成,页面将自动刷新
from selenium import webdriver
from selenium.webdriver.common.by import By
brower = webdriver.Chrome()
url = 'https://quote.eastmoney.com/center/gridlist.html#hs_a_board'
brower.get(url)
data = brower.find_elements(By.XPATH,'//tr[@class="odd"]/td[3] | //tr[@class="even"]/td[3]') #xpath的使用
data = brower.find_elements(By.XPATH,'//tr[@class="odd"]/td[9] | //tr[@class="even"]/td[9]')
# data = brower.find_elements(By.CSS_SELECTOR,'.odd') #css的使用
# data = brower.find_elements(By.CLASS_NAME,"mywidth")
for i in data:
print(i.text)
nextButton = brower.find_element(By.CSS_SELECTOR,".next.paginate_button")
nextButton.click()
# import requests
# import json
# url = 'https://90.push2.eastmoney.com/api/qt/clist/get?cb=jQuery1124005531437270239614_1634861401568&pn=1&pz=20&po=1&np=1&ut=bd1d9ddb04089700cf9c27f6f7426281&fltt=2&invt=2&fid=f3&fs=m:0+t:6,m:0+t:80,m:1+t:2,m:1+t:23&fields=f1,f2,f3,f4,f5,f6,f7,f8,f9,f10,f12,f13,f14,f15,f16,f17,f18,f20,f21,f23,f24,f25,f22,f11,f62,f128,f136,f115,f152&_=1634861401569'
# response = requests.get(url)
# # response.encoding = response.apparent_encoding
# print(response.status_code)
# data = response.text
# j= json.loads(data)
# for i in j['data']:
# for j in i['diff']:
# print(j['f14'])
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。