Note that there are some explanatory texts on larger screens.

plurals
  1. POPython Mechanize IncompleteRead Error
    primarykey
    data
    text
    <p>I am experimenting with mechanize and re to find the websites which correspond to a list of retail stores.</p> <p>I have been parsing Bing search results to grab the top result's url. Unfortunately, seemingly independent of the query, at random times I've been getting an httplib.IncompleteRead error. Even though I've got a workaround which follows, I'd like to understand what's happening.</p> <pre><code>def bingSearch(query): #query is the store's name, i.e. "Bob's Pet Shop" while True: try: bingBrowser.open('http://www.bing.com/search?q="' + query.replace(' ','+') + '"' ) htmlCode = bingBrowser.response().read() break except httplib.IncompleteRead: #Sleep for a little while and try again. </code></pre> <p>Other relevant info:</p> <ul> <li>Sometimes, for a single bing url, the program will to attempt to open and read that url multiple times, before a successful read without an IncompleteRead error.</li> <li>bingBrowser's headers attribute is set up to look nice.</li> <li>bingBrowser's robots attribute is set to false. </li> <li><a href="https://stackoverflow.com/questions/3670257/httplib-incomplete-read">httplib: incomplete read</a> ... I don't know anything about Apache so I wasn't able to understand the answer to the question, but it may be helpful to you. That said, I doubt that I'm having a similar problem (Why would bing.com be suffering from an Apache error?!)</li> </ul> <h2>Edit:</h2> <ol> <li>Replaced query.replace(' ','+') + '"' ) with urllib.urlencode(dict(q=query)) per JF Sebastian's suggestion - no change (I know this wasn't proposed as a solution).</li> <li>Suffered from an inexplicable urllib2.URLError on bingBrowser.open('<a href="http://www.bing.com/search?q=" rel="nofollow noreferrer">http://www.bing.com/search?q=</a>"' + query.replace(' ','+') + '"' )</li> <li>Got an xlwt related "String longer than 65535 characters" error - probably unrelated.</li> </ol> <p>Thanks in advance.</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.
 

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