Mechanize._response.httperror_seek_wrapper: HTTP Error refresh: The HTTP server returned a redirect error that would lead to an infinite loop.
0
0
Entering edit mode
9.6 years ago
ShahiRB ▴ 30

I will be thankful for helping me to solve this error.

My code is:

url='http://www.ncbi.nlm.nih.gov/tools/primer-blast/'

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

# Browser options
br.set_handle_equiv(True)
br.set_handle_redirect(True)
br.set_handle_referer(True)
#br.set_handle_refresh(True, max_time=1, honor_time=False)
br.set_handle_robots(False)
br.set_handle_refresh(mechanize._http.HTTPRefreshProcessor(), max_time=1)
# br.addheaders = [('User-agent', 'Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.0.1) Gecko/2008071615 Fedora/3.0.1-1.fc9 Firefox/3.0.1')]

# Want debugging messages?
#br.set_debug_http(True)
# br.set_debug_redirects(True)
#br.set_debug_responses(True)

br.open(url)
br.select_form(name="searchForm")

br.form.find_control(name="INPUT_SEQUENCE").__setattr__("value", str(sequence))
br.form.find_control(name='PRIMER5_START').__setattr__("value",str(primer5_start))
br.form.find_control(name='PRIMER5_END').__setattr__("value",str(primer5_end))
br.form.find_control(name='PRIMER3_START').__setattr__("value",str(primer3_start))
br.form.find_control(name='PRIMER3_END').__setattr__("value",str(primer3_end))
br.form.find_control(name='PRIMER_PRODUCT_MAX').__setattr__("value",str(max_product_size))
br.form.find_control(name='PRIMER_SPECIFICITY_DATABASE').items[2].selected = True
br.submit()
br.select_form(name="userGuidedForm)
br.form.find_control(name="USER_SEQLOC").items[0].selected = True
br.submit()
print br.response().read()

And the error is:

 File "./FIELT21_primer_1_generate_primer_v0.2.py", line 282, in <module>
    main()
  File "./FIELT21_primer_1_generate_primer_v0.2.py", line 224, in main
    str(400))
  File "./FIELT21_primer_1_generate_primer_v0.2.py", line 163, in scrap
    br.submit()
  File "/usr/lib/python2.7/site-packages/mechanize/_mechanize.py", line 541, in submit
    return self.open(self.click(*args, **kwds))
  File "/usr/lib/python2.7/site-packages/mechanize/_mechanize.py", line 203, in open
    return self._mech_open(url, data, timeout=timeout)
  File "/usr/lib/python2.7/site-packages/mechanize/_mechanize.py", line 255, in _mech_open
    raise response
mechanize._response.httperror_seek_wrapper: HTTP Error refresh: The HTTP server returned a redirect error that would lead to an infinite loop.
The last 30x error message was:
OK

Thanx

software error • 6.4k views
ADD COMMENT
0
Entering edit mode

Hello! I am having the same problem, could you fix it?

ADD REPLY
0
Entering edit mode

Hi, it was many years back. I forgot it how did I solve the issue. Now, I don't have the script with me to review (sad). You can try to take help from https://groups.google.com/g/www-mechanize-users or create a issue here https://github.com/python-mechanize/mechanize/issues. If I come across my old script I will certainly update you. KR, Raj

ADD REPLY
0
Entering edit mode

(so sad) anyway thanks for your help. I will consider your recommendations and hope you can find your script :)

ADD REPLY

Login before adding your answer.

Traffic: 1692 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6