Questions tagged [urllib]

Python module providing a high-level interface for fetching data across the World Wide Web. Predecessor to urllib2. In Python 3, urllib2 and urllib have been reorganized and merged into urllib.

For Python 2, the urllib module is the predecessor of the urllib2 module, while the latter still uses some functionality of the former.

For Python 3, the urllib package was reorganized. It now has no content of its own. All methods and classes are in several submodules:

Note that doesn't exist in Python 3 anymore.

3960 questions
1
vote
0 answers

Python requests module: Equivalent of cURL --data command

I'm trying to write a script that imitates a cURL command I make to change data on the target web page: curl -u username:password "https://website.com/update/" --data…
juiceb0xk
  • 949
  • 3
  • 19
  • 46
1
vote
3 answers

How to read in url in python and then print each URL on the website?

I am trying to figure out how to only read in each line that is a url from a website, every time I run the code I get the error: AttributeError: module 'urllib' has no attribute 'urlopen' My code is below import os import subprocess import…
nosh
  • 620
  • 3
  • 14
  • 50
1
vote
1 answer

Why can't I open a URL in Python 3?

I am unable to open a URL in Python3. I am using an online editor named Repl.it for coding (https://repl.it/languages/python3) Code: import urllib.request fp = urllib.request.urlopen("http://www.python.org") mybytes =…
1
vote
1 answer

Python - Poloniex trading api problems

Despite the number of posts regarding Poloniex / Python trading api access, I still can't figure out how to make this work on Python 3.6. Here is one version which, in my view, should word perfectly, but doesn't: req['command'] =…
Peter K.
  • 517
  • 3
  • 19
1
vote
2 answers

urllib.request.urlopen: ValueError: unknown url type

I have a long-standing issue with urllib.request. What I do: wahlrecht = urllib.parse.quote("http://www.wahlrecht.de/umfragen/") page = urllib.request.urlopen(url) Here's the full traceback I get: Traceback (most recent call last): File…
ben0it8
  • 505
  • 1
  • 6
  • 10
1
vote
1 answer

How do I get a partial result from http response python while data is still coming?

I am making a request to a server but the HTML page is very long and it takes a long time to send the whole data. I want to start processing as soon some data arrives. Like the browsers which renders as soon as there are data from top to bottom.…
Tamim Addari
  • 7,591
  • 9
  • 40
  • 59
1
vote
1 answer

zabbix API json request with python urllib.request

I'm working on my python project and I migrated from python2.6 to python 3.6. So I had to replace urllib2 with urllib.request ( and .error and .parse ). But I'm facing an issue I can't solve, here it is... I want to send a request written in JSON…
Gozu09
  • 43
  • 2
  • 5
1
vote
1 answer

How to see headers of urllib OpenerDirector before using open method

I'm getting "urllib.error.HTTPError: HTTP Error 401: Unauthorized" after trying this code: _HTTPHandler = urllib.request.HTTPBasicAuthHandler() _HTTPHandler.add_password(None,'http://192.168.1.205','admin','password') opener =…
MorgoZ
  • 2,012
  • 5
  • 27
  • 54
1
vote
1 answer

Error when using the .split() function with urllib.request

I am trying to split bbc's source into two parts in order to get the top headline: import urllib.request url = 'http://www.bbc.com/' page = urllib.request.urlopen(url) contents = page.read() page.close() split1 = '
Smich
  • 345
  • 1
  • 7
  • 17
1
vote
2 answers

urllib.error.HTTPError: HTTP Error 405: Not Allowed in python 3.X how to get rid of bot detection

I'm completely new to coding. I'm trying to create a program to collect data for me however when I code it to open the url, it says HTTPError: HTTP Error 405: Not Allowed I'm using Python, I installed Beautiful Soup but for some reason I get this…
dark
  • 11
  • 1
  • 2
1
vote
1 answer

Read part of a website by limiting bytes

I am trying to read several websites, get the information that I need, and then move on. Though the python code hangs on some websites. I've noticed in real browsers that at random times, the website fails to completely load, maybe its waiting on…
jsfa11
  • 483
  • 7
  • 19
1
vote
1 answer

Web scraping: read all href

I write a small script to read all hrefs from web page with python. But it has a problem. It doesn't read href="pages.php?ef=fa&page=n_fullstory.php&NewsIDn=1648" for example. code: import urllib import re urls =…
Karim Pazoki
  • 951
  • 1
  • 13
  • 34
1
vote
1 answer

Python requests library's '\t \n in response

I am doing a request to an API. The problem that I have is with the response. It's UTF-8 JSON, but I received the message with \t and \n and I can't decode it. Postman header information Connection →keep-alive Content-Encoding →gzip Content-Length…
1
vote
0 answers

Python - download a file that needs a cookie set

I have the following code import urllib f=open('ondemand.txt','r') for line in f: urllib.urlretrieve (line, "1.webm") In theory, it works, but the URLs need a cookie set. How would I go about it in the above scenario or do I need to move to…
pee2pee
  • 3,619
  • 7
  • 52
  • 133
1
vote
1 answer

AttributeError when creating ZipFile

Question I get an AttributeError: 'tuple' object has no attribute 'seek' when attempting to create a zipfile.ZipFile from a file path. I have no idea why, the traceback doesn't make any sense in relation to my code, is this a bug in the zipfile…
Jacob Birkett
  • 1,927
  • 3
  • 24
  • 49
1 2 3
99
100