在页面sou中找不到<option>标记

2024-09-21 11:47:16 发布

您现在位置:Python中文网/ 问答频道 /正文

在下面的土耳其语编码的网页中,当查看源代码时,我看不到显示日期的<option>标记。我需要它是因为我和美素擦伤了。你知道吗

http://millipiyango.gov.tr/sonuclar/_cs_sayisal.php

下面是我的python代码:

def fetchDates(product):
    Form = product.find('form', attrs = {'id':'form'})
    Select = Form.find('select',attrs={'name':'tarihList'})
    for element in Select(text=lambda text: isinstance(text, Comment)):
        element.extract() #to eliminate comment outs (just tried, didn't useful)
    print(Form.prettify()) #prints only <select bla bla></select>

    for option in Select.find_all('option'): #prints nothing
        print('value: %s, text: %s',format(option['value'], option.text))

输出为:

D:\wamp\www\mysite\scrap>python scrap.py 
<select id="sayisal-tarihList" name="tarihList" onchange="tarihSecildi(this)">
</select>


D:\wamp\www\mysite\scrap>

注意,如果我通过F12复制HTML的相关部分(右键单击<select>并选择“copy outer HTML”),我可以得到<option>值,但是BS无法获取它。你知道吗

有人能告诉我我错过了什么吗?你知道吗


Tags: textnameformidforfindproductselect

热门问题