0

我正在为 Steam 社区市场开发价格检查器应用程序。我使用以下代码从网站中提取了源代码,其中包括截至今天为止的所有销售。您能帮我获取“[[]]”符号之间的数据吗?

import requests
sites = [
    "https://steamcommunity.com/market/listings/730/AK-47%20%7C%20Redline%20%28Field-Tested%29"
]
for url in sites:
    r = requests.get(url)
    page_source = r.text
    page_source = page_source.split('\n')
    print("\nURL:", url) 
    
    for row in page_source[:]:
        print(row)
4

1 回答 1

0

我使用正则表达式来提取数据

import requests
import re
import json

sites = [
    "https://steamcommunity.com/market/listings/730/AK-47%20%7C%20Redline%20%28Field-Tested%29"
]
for url in sites:
    r = requests.get(url)
    page_source = r.text
    # print(page_source)
    results = re.search(r'var line1=\[.*\]',page_source).group()
    print(results[10:])
于 2020-12-19T09:46:31.000 回答