<html><head></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; ">Hello. This problem has got me stumped, and I've been trying to figure it out for more than a month.<div>This program checks to see if a college buyback site is buying back particular books.</div><div>I'm using mac OSX</div><div>Here's the code.</div><div><br></div><div><div>import urllib,urllib2</div><div>base_url="<a href="http://textbooks.com">http://textbooks.com</a>"</div><div>action="/BuyBack-Search.php?CSID=AQ2ZJKUWKZJBSD2T2DDMKMKB"</div><div>url=base_url+action</div><div>name="bb_isbns"</div><div>isbns="""0891917608 0307387895 0195070658 0137806922 074324754X\</div><div> 067149399x 0446556246 031604993X 0070322538"""</div><div>data={name:isbns}</div><div>encoded_data=urllib.urlencode(data)</div><div>text=urllib2.urlopen(url,encoded_data).read()</div><div>file_name="textbooks_trial.txt"</div><div>file=open(file_name,"w")</div><div>file.write(text)</div><div>file.close()</div><div>print "finished running program"</div><div>print "check file 'textbooks_trial.txt'"</div></div><div><br></div><div>When I go to the website(without using Python) and I paste the text (isbns) into the text box then enter it, it comes back with the error:</div><div><span class="Apple-style-span" style="color: rgb(202, 69, 21); font-family: Arial; font-size: 12px; "><b>  Oops... there may be a mistake here.  </b><ul><li>Sorry, your search could not be completed at this time. Please try again. (Error: BB-09-00-05)</li></ul></span><div><br></div></div><div>But the text I entered is still in the text entry box. When I click on the orange button ("Sell your Textbooks") a second time, it goes through.</div><div><br></div><div>The problem is that when I try to do this through Python, it returns the code with the error, and there's no orange button to click.</div><div>I tried submitting it again, hoping the second time would work, using the following code:</div><div><br></div><div>import urllib,urllib2</div><div><div>text="there may be a mistake here"</div><div>base_url="<a href="http://textbooks.com">http://textbooks.com</a>"</div><div>action="/BuyBack-Search.php?CSID=AQ2ZJKUWKZJBSD2T2DDMKMKB"</div><div>url=base_url+action</div><div>name="bb_isbns"</div><div>isbns="""0891917608 0307387895 0195070658 0137806922 074324754X\</div><div> 067149399x 0446556246 031604993X 0070322538"""</div><div>data={name:isbns}</div><div>encoded_data=urllib.urlencode(data)</div><div>while "there may be a mistake here" in text:</div><div>    text=urllib2.urlopen(url,encoded_data).read()</div><div>    file_name="textbooks_trial.txt"</div><div>    file=open(file_name,"w")</div><div>    file.write(text)</div><div>    file.close()</div><div>    print "tried doing the program"</div><div>print "finished running program"</div><div>print "check file 'textbooks_trial.txt'"</div></div><div><br></div><div>The result is an endless loop, where it prints out:</div><div>"tried running the program"</div><div><br></div><div>If anyone can figure out what I need to do, I'd be extremely grateful.</div><div>Thanks,</div><div>Ben</div><div><br></div><div><br></div></body></html>