第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問題,去搜搜看,總會(huì)有你想問的

使用 python3 從 html 源獲取列表

使用 python3 從 html 源獲取列表

慕運(yùn)維8079593 2023-12-11 10:12:34
我正在嘗試Cases從 獲取 COVID-19 陽性病例列表https://www.worldometers.info/,例如這個(gè)示例如下(~行號(hào):700):<script type="text/javascript">    Highcharts.chart('coronavirus-cases-linear', {        chart: {            type: 'line'        },        title: {            text: 'Total Cases'        },        subtitle: {            text: '(Linear Scale)'        },        xAxis: {            categories: ["Feb 15","Feb 16","Feb 17","Feb 18","Feb 19","Feb 20","Feb 21","Feb 22","Feb 23","Feb 24","Feb 25","Feb 26","Feb 27","Feb 28","Feb 29","Mar 01","Mar 02","Mar 03","Mar 04","Mar 05","Mar 06","Mar 07","Mar 08","Mar 09","Mar 10","Mar 11","Mar 12","Mar 13","Mar 14","Mar 15","Mar 16","Mar 17","Mar 18","Mar 19","Mar 20","Mar 21","Mar 22","Mar 23","Mar 24","Mar 25","Mar 26","Mar 27","Mar 28","Mar 29","Mar 30","Mar 31","Apr 01","Apr 02","Apr 03","Apr 04","Apr 05","Apr 06","Apr 07","Apr 08","Apr 09","Apr 10","Apr 11"]        },        yAxis: {            title: {                text: 'Total Coronavirus Cases'            }        },        legend: {            layout: 'vertical',            align: 'right',            verticalAlign: 'middle'        },        credits: {            enabled: false        },        series: [{            name: 'Cases',            color: '#33CCFF',            lineWidth: 5,            ## I NEED THIS LIST        responsive: {            rules: [{                condition: {                    maxWidth: 800                },                chartOptions: {                    legend: {                        layout: 'horizontal',                        align: 'center',                        verticalAlign: 'bottom'                    }                }            }]        }    });它確實(shí)會(huì)抓取文件,但之后我不知道如何獲取數(shù)據(jù)。我正在尋找的列表帶有注釋## I NEED THIS LIST。請(qǐng)幫忙。
查看完整描述

1 回答

?
aluckdog

TA貢獻(xiàn)1847條經(jīng)驗(yàn) 獲得超7個(gè)贊

你可以為它寫一個(gè)正則表達(dá)式


import requests as req

import re


resp = req.get("https://www.worldometers.info/coronavirus/country/spain/")

p = re.compile(r"(?<=name:\s'Cases')[\s\S]+?data:\s(\[.*?\])")

p.findall(resp.text)[0]

https://img1.sycdn.imooc.com/657670380001af0306130450.jpg

查看完整回答
反對(duì) 回復(fù) 2023-12-11
  • 1 回答
  • 0 關(guān)注
  • 145 瀏覽

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)