1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61
| import requests import pandas as pd from bs4 import BeautifulSoup
def api(urls): response = requests.get(urls)
if response.status_code == 200: html_content = response return html_content
def bs(): jjwd = 'http://caf-qibei.com/index?type=html' html = api(jjwd).text soup = BeautifulSoup(html, 'html.parser') return soup
def temps(): tr_tags = bs().find_all('tr')
temps = [ ( tr.find_all('a', href=True)[0].text.strip(), float(tr.find('td', {'colspan': '3'}).text.strip()) ) for tr in tr_tags if len(tr.find_all('a', href=True)) >= 2 and tr.find('td', {'colspan': '3'}) and tr.find('td', {'colspan': '3'}).text.strip().replace('.', '', 1).isdigit() ] temp = pd.DataFrame(temps) return temp
def js(url): html = api(jsl=url).json() return html
etf_jsl = 'https://www.jisilu.cn/data/etf/etf_list/?___jsl=LST___t=1693819271762&volume=500&unit_total=2&rp=25'
jsl = js(etf_jsl)['rows'] print(jsl)
|