我正在尝试从产品页面中获取其变体/标识,但不知道如何使用bs4在html中的javascript中。
我一无所知,想知道能够提取此数据的最快代码。
import requests
from bs4 import BeautifulSoup as bs
session = requests.session()
def get_ava_sizes():
global session
endpoint = 'https://fasttimes.com.au/nike-sb-zoom-blazer-mid-iso-white-black-safety-orange-80817'
response = session.get(endpoint)
soup = bs(response.text, 'html.parser')
#print(response.text)
select = soup.find('script', {'type':'text/javascript'})
sizes = select.find_all('id')
ava_sizes = []
for size in sizes:
size_id = size['']
return ava_sizes
print(get_ava_sizes())
答案 0 :(得分:0)
如下?我假设排除“ label”:“ Size”-第一个ID。
export default class XmlSerializerWrapper {
private serializer: XMLSerializer;
constructor() {
this.serializer = new XMLSerializer();
}
public serializeToString(doc: Document) {
return this.serializer.serializeToString(doc);
}
}