Problem in reading a URL

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • ×ñõóÜíèç ÁúíáëÞ

    #1

    Problem in reading a URL

    Hi,

    I get an error, when I am trying to read URL.
    Where is the Problem?

    Thank u very much for all ideas!!!

    sincerely

    Chrysanthi


    from urllib2 import *

    filename=urlope n('http://www.ncbi.nlm.ni h.gov/entrez/viewer.fcgi?que ry_key=1&db=nuc leotide&qty=1&c _start=1&uids=& dopt=fasta&disp max=20&sendto=t ')

    for line in filename.readli nes():

    print line,


    Error: History is unavailable either because it has expired or because
    your system cannot accept <A
    href='/entrez/query/static/faq.html#Accept scookies'>cooki es</A>
  • scum

    #2
    Re: Problem in reading a URL

    This is not a python problem. That is the text of the site when you go
    to it. The site uses cookies to store a session of your visit. Using
    python bypasses that cookie and throws an error. You will be better
    served using teh mechanize library.



    Even though you may not get far, since the site you are attempting to
    search prevents robots from scouring their site.
    >>import mechanize
    >>from mechanize import Browser
    >>br= Browser()
    >>br.open("http ://www.ncbi.nlm.ni h.gov/entrez/")
    Traceback (most recent call last):
    File "<stdin>", line 1, in <module>
    File
    "/Library/Frameworks/Python.framewor k/Versions/2.5/lib/python2.5/site-packages/mechanize-0.1.4b-py2.4.egg/mechanize/_mechanize.py",
    line 156, in open
    File
    "/Library/Frameworks/Python.framewor k/Versions/2.5/lib/python2.5/site-packages/mechanize-0.1.4b-py2.4.egg/mechanize/_mechanize.py",
    line 214, in _mech_open
    mechanize._resp onse.httperror_ seek_wrapper: HTTP Error 403: request
    disallowed by robots.txt

    Comment

    Working...