Python - Requests/RoboBrowser - ASPX POST JavaScript

后端 未结 1 1022
一生所求
一生所求 2021-01-06 18:12

I am porting a bash script that uses curl and POSTs the payloads in the code to the URL\'s and works. The basic issue is that, with robobrowser, I\'m running into trouble po

1条回答
  •  迷失自我
    2021-01-06 18:43

    Solved

    After much googling, re-posting for help on reddit and then randomly stumbling this RoboBrowser issue that showed me how to properly use the 'fields.add_field()' method; the problem is solved.

    e.g.

    b_e_arg = robobrowser.forms.fields.Input('\')
    
    b_e_target = robobrowser.forms.fields.Input('\')
    
    In [30]: form_find_b.add_field(b_e_target)
    In [31]: form_find_b.add_field(b_e_arg)
    

    Once the form was updated with these values, the form submit to "PhoneLists.aspx" works as expected.

    In [33]: m.submit_form(form_find_b)
    
    In [34]: m.url
    Out[34]: u'http://example/PhoneLists.aspx'
    
    In [35]: m.parsed.findAll('div', id='PhoneListsControl_phoneListMembersText')
    Out[35]: [
      Work  
    ] In [36]: m.parsed.findAll('input', id='PhoneListsControl_phoneListDetail__ctl2_number') Out[36]: []

    I hope anyone else that has to scrape ASPX sites finds this useful. Happy hacking to all!

    0 讨论(0)
提交回复
热议问题