Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/google-cloud-platform/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何从div标签中提取强数据? 我正在使用Python刮取数据。有人能帮助我如何使用python从div中提取强数据吗 <div class="type"><span class="tag_ts" title="Time sale">Time sale</span></div><del>$35.90</del><strong title="Discounted Price">$12.90</strong> 我的输出是:时间销售$35.90$12.90_Python_Beautifulsoup - Fatal编程技术网

如何从div标签中提取强数据? 我正在使用Python刮取数据。有人能帮助我如何使用python从div中提取强数据吗 <div class="type"><span class="tag_ts" title="Time sale">Time sale</span></div><del>$35.90</del><strong title="Discounted Price">$12.90</strong> 我的输出是:时间销售$35.90$12.90

如何从div标签中提取强数据? 我正在使用Python刮取数据。有人能帮助我如何使用python从div中提取强数据吗 <div class="type"><span class="tag_ts" title="Time sale">Time sale</span></div><del>$35.90</del><strong title="Discounted Price">$12.90</strong> 我的输出是:时间销售$35.90$12.90,python,beautifulsoup,Python,Beautifulsoup,我需要12.90美元,你只要换一下就行了 prdt_price=container.find_all('div',{'class':'prc'}) 到 要从强元素中提取文本(如果您确定容器中的所有元素都有一个强元素),可以使用container.strong.text 要仅获取强文本,请使用以下内容: for container in containers: prdt_price=container.find_all('div',{'class':'prc'}) price=p

我需要12.90美元,你只要换一下就行了

prdt_price=container.find_all('div',{'class':'prc'})


要从强元素中提取文本(如果您确定容器中的所有元素都有一个强元素),可以使用
container.strong.text

要仅获取强文本,请使用以下内容:

for container in containers:
    prdt_price=container.find_all('div',{'class':'prc'})
    price=prdt_price[0].strong.text
    print(price)
或者,您可以将其缩减为:

for container in containers:
    print(container.find_all('div',{'class':'prc'})[0].strong.text)
for container in containers:
    prdt_price=container.find_all('div',{'class':'prc'})
    price=prdt_price[0].strong.text
    print(price)
for container in containers:
    print(container.find_all('div',{'class':'prc'})[0].strong.text)