当我br.submit()时,机械化给出错误

时间:2013-06-26 06:03:30

标签: javascript python-2.7 mechanize

import mechanize
import cookielib
import urllib2
from bs4 import BeautifulSoup
import sys

br = mechanize.Browser()
cj = cookielib.LWPCookieJar()
br.set_cookiejar(cj)

br.set_handle_equiv(True)
#br.set_handle_gzip(True)

br.set_handle_referer(True)
br.set_handle_redirect(mechanize.HTTPRedirectHandler)

br.set_handle_refresh(mechanize.HTTPRefreshProcessor(),max_time=1)

br.set_debug_http(True)
br.set_debug_redirects(True)
br.set_debug_responses(True)

br.addheaders=[('User-agent','Mozilla/5.0')]#Necessary or not, depending on page

r=br.open('http://vizier.u-strasbg.fr/vizier/surveys.htx')
#print r.read()
#r1=br.r()
`enter code here`#print r1.read()

#print br.title()
#print r.info()
for f in br.forms():#prints the html form-values
   print f

star=raw_input('Which source would you like to search? ')
radius=raw_input('At which search radius (in arcsec)? ')
#print br.forms
br.select_form(nr=0)
form=br.form
form['-source']=sys.argv[0]
form['-c']=star
form['-c.rs']=radius
response=br.submit() #This 'hits' the submit button
print response.read()

使用mechanize(等人)我正在尝试从网站收集数据,当我提交它时,它运行得相当顺利,直到我查看输出,我发现错误被提出(可能是在Javascript中):< / p>

<EM>The following unexpected problem occured in</EM> <B>VizieR</B>:<BR>
No catalog or table matching your choices.<BR><BR>
Return to the <a href='http://vizier.u-strasbg.fr/viz-bin/VizieR'>VizieR main Page</a>
</div>
</div>
<div class='headmsg'><span class='optncat'> having potential matches</span></div><DIV class='report'>
<H3 >Report:</H3>
<EM>If you can't find a solution, <A HREF="mailto:cds-question@unistra.fr?Subject=No%20Suitable%20Catalog%20or%20Table%20%28%40vizier.u-strasbg.fr%29&Cc=francois%40simbad.u-strasbg.fr">report to CDS</A> and insert into your message the following details:</EM><P>

我无法弄清楚发生了什么事,但看到我对所有这些都很陌生,我可能无论如何都不会有机会。希望有人可以指出我的错误。

感谢。

0 个答案:

没有答案