Questions tagged [urllib2]

urllib2 is a builtin python 2 module that defines functions and classes to help with URL actions. It is notably unsatisfactory and has been replaced in python 3 and by third-party libraries.

urllib2 is a module that defines functions and classes to help with URL actions (basic and digest authentication, redirections, cookies, etc). It supersedes urllib in Python 2, and in python 3 has been superseded by a new library called urllib.

In addition, the requests third party module has become a de facto standard to accomplish the same tasks.

2960 questions
1
vote
1 answer

Automate downloading images off Google

I'm very new to Python and I'm trying to create a tool that automates downloading images off Google. So far, I have the following code: import urllib def google_image(x): search = x.split() search = '%20'.join(map(str, search)) url =…
user3105664
  • 179
  • 3
  • 6
  • 11
1
vote
1 answer

Python urllib2 gives error 503

I m trying to run the following simple code: import urllib2 import base64 username = "some_user" password = "some_pass" url = "some_url" req = urllib2.Request(url) authheader = "Basic %s" % base64.encodestring('%s:%s' % (username,…
user1724641
  • 331
  • 1
  • 11
1
vote
1 answer

Passing structs through urllib2

I'm trying to interact with the mailchimp api and I'm having issues with the subscribe method. I've tracked down the problem to where I encode the data. It seems to be that urllib.urlencode isn't encoding my struct correctly. The struct in…
neatnick
  • 1,489
  • 1
  • 18
  • 29
1
vote
1 answer

Python URL redirection - Handle 302 which moves to 404

I know we can handle redirection with requests and urllib2 packages. I do not want to use requests as it is not a prebuilt package. Please help me with urllib2 to handle a URL which takes a 302 and then moves to 404. I am not concerned about the 404…
Sathy
  • 303
  • 2
  • 8
  • 18
1
vote
1 answer

Slow urllib.urlopen with wired internet connection (to local server)

I have the following /etc/hosts 127.0.0.1 my-server-name Then I run this code: import urllib2 f = urllib2.urlopen('http://my-server-name') print f.read() If I’m connected to the interned via wifi (or if the Ethernet interface is off), the…
fsiddi
  • 101
  • 6
1
vote
0 answers

Python URLLIB2 - when downloading from FTP

I am trying to add a component to my application that grabs a file from an FTP location for processing. The FTP server accepts anonymous logins, but when using the code below, I receive a URLError 550 Access Denied. I have searched various…
1
vote
2 answers

Detecting soft 404 redirects in Python

I'm building a script that every now and then crawls through an online story archive and detects when a story has been deleted. However, when a story is deleted, I discovered that going to the story's URL does not return a HTTP 404 response code.…
1
vote
1 answer

504 : Gateway Timeout with urllib2

When I try to read the source of the page , I get the following output …
GingerNinja23
  • 162
  • 2
  • 11
1
vote
2 answers

wx.Image from image URL

Well I've been doing a ton of searching and there doesn't seem to be too many people talking about this. With the help of the documentation for wxPython, I've got this far. I'm looking to create a wx.Image widget from an image URL.…
1
vote
2 answers

Install urllib2 in Arch Linux

I am trying to install the urllib2 module in Arch Linux as I need to run a Python code. The error that the Python code outpus is: File "PiMiner/PiMiner.py", line 3, in import sys, subprocess, time, urllib2, socket Now, when I runt his code…
Andrei RRR
  • 3,068
  • 16
  • 44
  • 75
1
vote
3 answers

urllib2 download HTML file

Using urllib2 in Python 2.7.4, I can readily download an Excel file: output_file = 'excel.xls' url = 'http://www.nbmg.unr.edu/geothermal/GEOTHERM-30Jun11.xls' file(output_file, 'wb').write(urllib2.urlopen(url).read()) This results in the expected…
Dylan Hettinger
  • 731
  • 1
  • 11
  • 20
1
vote
0 answers

Python: intermittent errors downloading web page with urllib2

I have a web scraping program that downloads a web page a few times every hour. On about one out of 15 or 20 attempts I get: [Errno 10054] An existing connection was forcibly closed by the remote host or [Errno 10060] A connection attempt failed…
foosion
  • 7,619
  • 25
  • 65
  • 102
1
vote
2 answers

using urllib2 to execute URL and return rendered HTML output, not the HTML itself

urllib2.urlopen("http://www.someURL.com/pageTracker.html").read(); The code above will return the source HTML at http://www.google.com. What do I need to do to actually return the rendered HTML that you see when you visit google.com? I essentially…
Ryan Martin
  • 1,613
  • 3
  • 24
  • 36
1
vote
0 answers

Issues relating to a Google drive keylogger

I'm going to try to word this as exact as possible. So I got this Python (using 3.3) keylogger that I am working on and everything is working flawless besides the fact that it doesn't write the logged input into the Form spreadsheet that I have…
Divine
  • 13
  • 1
  • 3
1
vote
0 answers

how to make python urllib2 download file with authentication, gui (only showing downloaded file %) and resume capability?

so far i have done this: import urllib2, base64, os def dl(): dwnld="http://xxx.xxx.xxx.xxx:xx/user/file.zip" username="user" password="pass" req=urllib2.Request(dwnld) base64str=base64.encodestring('%s:%s' % (username,…
1 2 3
99
100