Questions tagged [urlopen]

The urlopen is a method of the urllib library in Python, used to open a particular URL.

The urlopen is a method of the urllib library in Python, used to open a particular URL. As a result, a file-like object is returned that contains information about the URL - headers, response data and other details about the requested URL resource.

369 questions
1
vote
1 answer

Python: No connection could be made because the target machine actively refused it

I having a multi threaded python program, It will continuously open connection with a local URL(http://testing.com/sendMessages_mock.php), I have installed the WAMP and having sendMessages_mock.php file in local for testing purpose. Sometimes, I get…
Muthu
  • 1,550
  • 10
  • 36
  • 62
1
vote
2 answers

Python urllib2.urlopen bug: timeout error brings down my Internet connection?

I don't know if I'm doing something wrong, but I'm 100% sure it's the python script brings down my Internet connection. I wrote a python script to scrape thousands of files header info, mainly for Content-Length to get the exact size of each file,…
Shane
  • 4,875
  • 12
  • 49
  • 87
1
vote
1 answer

Get filename when using urllib.urlopen

I'm using urllib.urlopen to read a file from a URL. What is the best way to get the filename? Do servers always return the Content-Disposition header? Thanks.
Mridang Agarwalla
  • 43,201
  • 71
  • 221
  • 382
1
vote
2 answers

unbuffered urllib2.urlopen

I have client for web interface to long running process. I'd like to have output from that process to be displayed as it comes. Works great with urllib.urlopen(), but it doesn't have timeout parameter. On the other hand with urllib2.urlopen() the…
vartec
  • 131,205
  • 36
  • 218
  • 244
1
vote
0 answers

Will opener.open() affects urllib2.urlopen()'s behavier such as using proxy?

I wanna swap using/notUsing Proxy when request failed, and I wrote the code below. But I found that if enable_proxy is true and the request failed, then the next try using urllib2.urlopen will also use proxy, why? opener =…
Dodou Wang
  • 29
  • 7
1
vote
1 answer

Why does Python 3 urllib redirect to Yahoo?

I am using urlopen in urllib.request in Python 3.5.1 (64-bit version on Windows 10) to load content from www.wordreference.com for a French project. Somehow, whenever I request anything outside the domain itself, page content is instead loaded from…
cp289
  • 11
  • 2
1
vote
1 answer

Print HTML From Url

So I want to print out the HTML of a website from urllib.request import urlopen http = urlopen('http://www.google.de/').read() print(http) But in the output all newlines are printed as \n and the string begins with a b' which has something to do…
Matombo
  • 77
  • 1
  • 9
1
vote
1 answer

How to By pass WP super cache using python?

I'm trying to collecting data from a frequently updating blog, so I simply use a while loop which includes urllib2.urlopen("http:\example.com") to refresh the page every 5 minutes to collect the data I wanted. But I notice that I'm not getting the…
Shane
  • 4,875
  • 12
  • 49
  • 87
1
vote
1 answer

Python auth_handler not working for me

I've been reading about Python's urllib2's ability to open and read directories that are password protected, but even after looking at examples in the docs, and here on StackOverflow, I can't get my script to work. import urllib2 # Create an…
Parker
  • 8,539
  • 10
  • 69
  • 98
1
vote
2 answers

Mp3 download urllib.request.urlopen() Time-out

I got a list named href_w with a bunch of mp3 links to download, but when I execute this piece of code, it gives me an error: # Download file print(color.BLUE + "\n[*] Downloading requested mp3(s) ..." + color.END) for link in href_w: url =…
1
vote
0 answers

jython open image from online

For my Python college class I am trying to open an image from online to add to another image (using Jython). My code so far is: def addLogo(lgPic): import urllib logo = urllib.urlopen("http://www.wsiab.net/BITsoft/Lab7/csumb-logo-white.png") …
WSiaB
  • 11
  • 2
1
vote
0 answers

Scraping with urlopen do not work with a specific server

The following code in Python, usually gives me the html of a website specified in the url variable. Urlopen works correctly. The problem: with a particular website from now I am no more able to make this code working. from urllib.request import…
Michele Benolli
  • 55
  • 1
  • 11
1
vote
1 answer

python3 urrlib.request.urlopen UnicodeEncodeError: 'ascii'

I have a problem with url's request: req = 'https://www.facebook.com/127573287311337' handler = urllib.request.urlopen(req, timeout=30) An Exception is raise: Traceback (most recent call last): File…
1
vote
1 answer

how to fix python, urlopen error [Errno 8], using eventlet green

Python novice here. I'm making a lot of asynchronous http requests using eventlet and urllib2. At the top of my file I have import eventlet import urllib from eventlet.green import urllib2 Then I make a lot of asynchronous http requests that…
hackstar15
  • 1,259
  • 1
  • 10
  • 14
1
vote
1 answer

Which of these is a good way to request an API?

Whenever looking at API libraries for Python, there seems to be about half of them simply using: response = urllib2.urlopen('https://www.example.com/api', data) and about half using: connection = httplib.HTTPSConnection('www.example.com/api') # ...…
orokusaki
  • 55,146
  • 59
  • 179
  • 257