Using mechanicalsoup to set value of form element w/o a name

前端 未结 2 1133
刺人心
刺人心 2020-12-02 00:47

I have searched through all mechanicalsoup & beautifulsoup documentation but can\'t figure out how to set the value of a form element using \'id\' (because it doesn\'t h

相关标签:
2条回答
  • 2020-12-02 01:05

    Without a name attribute, the input will be quite useless when submitting the form, since the form data will be computed based on this name attribute. Most likely this input will be used by JavaScript, not by form submission, and MechanicalSoup won't help you with JavaScript. See:

    https://mechanicalsoup.readthedocs.io/en/stable/faq.html#form-submission-has-no-effect-or-fails

    In short: you probably want to use Selenium instead.

    0 讨论(0)
  • 2020-12-02 01:29

    After more research, I learned I should be using Selenium for this case (not mechanicalsoup). I used this guide which did exactly what I needed on the first try.

    http://stanford.edu/~mgorkove/cgi-bin/rpython_tutorials/Scraping_a_Webpage_Rendered_by_Javascript_Using_Python.php

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