[Tutor] Problem

Steven D'Aprano steve at pearwood.info
Sat Dec 27 03:27:42 CET 2014

On Fri, Dec 26, 2014 at 04:16:17PM +0000, salisme salisme wrote:
> Hello

> I am having a big problem trying to open a url that I have created by 
> concatenating a raw_input on to an already existing url. When I copy 
> and paste the url in to the search bar it works fine but when I try to 
> open it using urllib.request.urlopen(url) it givesme a 505 HTTP error. 

505 HTTP error means "version not supported". I would be very surprised 
if that is the error you receive. Please copy and paste (do not re-type 
from memory!) the *exact* error you get.

> From reading on the web I think the problem is the url I am using is 
> not the full url, how do I get this full url from what I have, I tried 
> to use geturl() but it wouldn't let me import it?
> Please help!

> import reimport urllibfrom urllib.request import urlparsefrom 
> urllib.request import urlopenfrom urllib.request import 
> urlretrievefrom bs4 import BeautifulSoup as bs choice = input("Choose 
> artist and album name in following format : Artist 'x' album 'y'") 
> baseurl = "http://www.ebay.co.uk/sch/Records-/176985/i.html?_nkw=" + 
> choice + '&_pgn=1'

All the formatting from your code is screwed up. Also you say above that 
you use "raw_input", but your code shown here actually uses "input", a 
different function.

Please COPY and PASTE the **exact** code you are actually using, do not 
re-type it from memory, and please send as plain text so the formatting 
doesn't get screwed up.

I also see you are trying to connect to Ebay. Ebay will try very, very, 
very hard to prohibit "bots" (i.e. programs like the one you are 
writing) from talking to the server. It will refuse to talk to anything 
it thinks is not a human being using a browser. That means it will take 
a lot of hard work to get this programming working:

- you may need to set the user-agent to something that looks 
  like a browser;

- you may need to set the referrer to something from Ebay;

- you may need to use cookies;

- you may need to run Javascript to make things work correctly.

All these things can be done, but it will require work and possibly 
third-party libraries.

Start with showing us the actual code you use, the actual error given, 
and show us the actual URL used.

Thank you,


More information about the Tutor mailing list