Note that there are some explanatory texts on larger screens.

plurals
  1. POError in using Python/mechanize select_form()?
    primarykey
    data
    text
    <p>I am trying to scrap some data from a website. The scripts I am trying to write, should get the content of the page:</p> <pre><code>http://www.atpworldtour.com/Rankings/Singles.aspx </code></pre> <p>Should simulate the user going trough every option for Additional Standings and the dates and simulate clicking on Go then after fetching the data should use the back function.</p> <p>For now I have been trying to just select this option for Additional Standing:</p> <pre><code> &lt;option value="101" &gt;101-200&lt;/option&gt; </code></pre> <p>Here is my (poor) attempt to try to do this:</p> <pre><code>from mechanize import Browser from BeautifulSoup import BeautifulSoup import re import urllib2 br = Browser(); br.open("http://www.atpworldtour.com/Rankings/Singles.aspx"); br.select_form(nr=0); br["r"] = "101"; response = br.submit(); </code></pre> <p>However it just fails on the select_form(nr=0) which should be selecting the first form.</p> <p>This is the log returned by Python:</p> <pre><code>&gt;&gt;&gt; from mechanize import Browser &gt;&gt;&gt; &gt;&gt;&gt; from BeautifulSoup import BeautifulSoup &gt;&gt;&gt; import re &gt;&gt;&gt; import urllib2 &gt;&gt;&gt; &gt;&gt;&gt; &gt;&gt;&gt; &gt;&gt;&gt; br = Browser(); &gt;&gt;&gt; br.open("http://www.atpworldtour.com/Rankings/Singles.aspx"); &lt;response_seek_wrapper at 0x311bb48L whose wrapped object = &lt;closeable_response at 0x311be88L whose fp = &lt;socket._fileobject object at 0x0000000002C94408&gt;&gt;&gt; &gt;&gt;&gt; br.select_form(nr=0); Traceback (most recent call last): File "&lt;stdin&gt;", line 1, in &lt;module&gt; File "build\bdist.win-amd64\egg\mechanize\_mechanize.py", line 505, in select_ form File "build\bdist.win-amd64\egg\mechanize\_html.py", line 546, in __getattr__ File "build\bdist.win-amd64\egg\mechanize\_html.py", line 559, in forms File "build\bdist.win-amd64\egg\mechanize\_html.py", line 228, in forms mechanize._html.ParseError </code></pre> <p>I could not find a proper explanation of all the functions in the mechanize home page. Can anyone either point me to a proper tutorial for using forms and Mechanize or help me on this particular issue ? </p> <p>Anthony</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload