pandas 使用Python进行网页抓取-因为当我使用FOR IN时,它只返回一个字符串

hgb9j2n6  于 2022-12-02  发布在  Python
关注(0)|答案(1)|浏览(103)

因为当我打印项目“Vagas”时,它们会返回我需要的所有字符串,但是当我打印“on_click”时,它只返回一个字符串,而且据我所知,它只返回最后一个字符串,忽略了其他字符串。

soup = BeautifulSoup(stringue, "html.parser")

Vagas = soup.find_all(title="Vaga disponível.")

for teste2 in Vagas:
    on_click = teste2.get('onclick')

print(on_click)

《流浪汉》的回归。

`<input id="ctl00_ctl00_Content_Content_rpt_turno_4_ctl01_imb_vaga_1" name="ctl00$ctl00$Content$Content$rpt_turno_4$ctl01$imb_vaga_1" onclick="javascript:window.open('Cadastro.aspx?id_agenda=0&amp;id_turno=29/11/2022 3:00:00;29/11/2022 4:00:00&amp;data=29/11/2022&amp;id_turno_exportador=198397&amp;id_turno_agenda=61298&amp;id_transportadora=23213&amp;id_turno_transp=68291&amp;id_Cliente=40300&amp;codigo_terminal=40300&amp;codigo_empresa=1&amp;codigo_exportador=24978&amp;codigo_transportador=23213&amp;codigo_turno=4&amp;turno_transp_vg=68291','_blank','height=850,width=1000,top=(screen.width)?(screen.width-1000)/2 : 0,left=(screen.height)?(screen.height-700)/2 : 0,toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=no');" src="../App_Themes/SisLog/Images/add-document.gif" style="height:20px;border-width:0px;" title="Vaga disponível." type="image"/>, 

<input id="ctl00_ctl00_Content_Content_rpt_turno_6_ctl01_imb_vaga_1" name="ctl00$ctl00$Content$Content$rpt_turno_6$ctl01$imb_vaga_1" onclick="javascript:window.open('Cadastro.aspx?id_agenda=0&amp;id_turno=29/11/2022 5:00:00;29/11/2022 6:00:00&amp;data=29/11/2022&amp;id_turno_exportador=198397&amp;id_turno_agenda=61298&amp;id_transportadora=23213&amp;id_turno_transp=68291&amp;id_Cliente=40300&amp;codigo_terminal=40300&amp;codigo_empresa=1&amp;codigo_exportador=24978&amp;codigo_transportador=23213&amp;codigo_turno=6&amp;turno_transp_vg=68291','_blank','height=850,width=1000,top=(screen.width)?(screen.width-1000)/2 : 0,left=(screen.height)?(screen.height-700)/2 : 0,toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=no');" src="../App_Themes/SisLog/Images/add-document.gif" style="height:20px;border-width:0px;" title="Vaga disponível." type="image"/>,`

返回“on_click”

javascript:window.open('Cadastro.aspx?id_agenda=0&id_turno=29/11/2022 19:00:00;29/11/2022 20:00:00&data=29/11/2022&id_turno_exportador=198397&id_turno_agenda=61298&id_transportadora=23213&id_turno_transp=68291&id_Cliente=40300&codigo_terminal=40300&codigo_empresa=1&codigo_exportador=24978&codigo_transportador=23213&codigo_turno=20&turno_transp_vg=68291','_blank','height=850,width=1000,top=(screen.width)?(screen.width-1000)/2 : 0,left=(screen.height)?(screen.height-700)/2 : 0,toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=no');
kgsdhlau

kgsdhlau1#

将print语句放在for循环中:

for teste2 in Vagas:
    on_click = teste2.get('onclick')
    print(on_click)

相关问题