logo
down
shadow

Same URL request fails with python->urllib but not with curl


Same URL request fails with python->urllib but not with curl

By : user2955954
Date : November 22 2020, 10:48 AM
may help you . Just to explain what was the problem. You needed to provide the User-Agent header:
code :
request = urllib.request.Request(url)
request.add_header('User-Agent', 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/39.0.2171.95 Safari/537.36')

data = urllib.request.urlopen(request)
Getting MyMemory search, with mandatory "langpair" attribute :
  URL : http://api.mymemory.translated.net/get?langpair=en%7Cfr&q=something+to+translate
  Response data : b'{"responseData":{"translatedText":"quelque chose \\u00e0 trad'


Share : facebook icon twitter icon
Urllib raising invalid argument URLError in Python 3, urllib.request.urlopen

Urllib raising invalid argument URLError in Python 3, urllib.request.urlopen


By : user2344526
Date : March 29 2020, 07:55 AM
around this issue Maybe try turning off the firewall? Since you are on Windows, that might be the problem.
HTTPConnection.request fails but urllib.request.urlopen works?

HTTPConnection.request fails but urllib.request.urlopen works?


By : Cloud4G
Date : March 29 2020, 07:55 AM
Does that help In HTTP, only POST requests are supposed to have a body. The third parameter to request() is actually the body (see http://docs.python.org/py3k/library/http.client.html#http.client.HTTPConnection.request) - just build the URL as shown in the second example.
Curl request in Python by urllib or urllib2

Curl request in Python by urllib or urllib2


By : Johan van Winden
Date : March 29 2020, 07:55 AM
will help you Like moliware said, all is right except 'll' : '55.828299%2C49.081782', it should be : 'll': '55.828299,49.081782'
Requests, Mechanize, urllib fails but cURL works

Requests, Mechanize, urllib fails but cURL works


By : Khingyo
Date : March 29 2020, 07:55 AM
it helps some times This process wasn't totally straightforward so I thought I'd post a new answer to make it easy to follow for others.
Following this thread, I needed to install these libraries get SNI to work with Python 2:
code :
pip uninstall pyOpenSSL
pip install pyOpenSSL==0.13 ndg-httpsclient pyasn1
Command /usr/local/opt/python/bin/python2.7 -c "import setuptools, tokenize;__file__='/private/var/folders/04/3f_y5fw166v03k7b51j1tsl80000gn/T/pip_build_alex/cryptography/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /var/folders/04/3f_y5fw166v03k7b51j1tsl80000gn/T/pip-7QR71B-record/install-record.txt --single-version-externally-managed --compile failed with error code 1 in /private/var/folders/04/3f_y5fw166v03k7b51j1tsl80000gn/T/pip_build_alex/cryptography
Storing debug log for failure in /Users/alex/.pip/pip.log
$ pip show pyOpenSSL
---
Name: pyOpenSSL
Version: 0.14
Location: /usr/local/lib/python2.7/site-packages
Requires: cryptography, six
import requests
response = requests.get("http://datamuster.marketdatasuite.com")

(...lots of errors...)
    raise ConnectionError(err, request=request)
requests.exceptions.ConnectionError: ('Connection aborted.', error(54, 'Connection reset by peer'))
pip uninstall pyOpenSSL
pip install pyOpenSSL==0.13
import requests
requests.get("http://datamuster.marketdatasuite.com")

<Response [200]>
Convert cURL to urllib request

Convert cURL to urllib request


By : Surendra Singh
Date : March 29 2020, 07:55 AM
Does that help I have a cURL
Related Posts Related Posts :
  • Testing logging output with pytest
  • How do I change my default working directory for Python (Anaconda) on VSCode?
  • .lower() for x in list, not working, but works in another scenario
  • Program gives error "List indices must not be string"
  • pyqt: Memory Usage
  • Confused about classes in Learn Python the Hard Way ex43?
  • Extracting unrecognized information from many CSV files
  • How do I connect to Postgresql server from Python?
  • Append rows to a pandas DataFrame without making a new copy
  • Scrapy: Importing a package from the project that's not in the same directory
  • launching Excel application using Python to view the CSV file , but CSV file is opening in read mode and cant view the d
  • Making a list in user-defined functions
  • Pyserial microcontroller to host communication
  • Plotting a line in between subplots
  • function not returning value. Error "NameError: name 'urlss' is not defined"
  • How to perform cartesian product with Tensorflow?
  • Multiple independent random number streams from single seed
  • I Need a simple and short python3 code that count secounds in a background process
  • No module named constants
  • from django 1.4 to django 1.5- argument 'verify_exists' what s replacement?
  • Slash replacement inside a raw string
  • Reordering columns/rows of a pivot_table?
  • MySQLdb.cursors.Cursor.execute does not work
  • Python module being reimported when imported at different places
  • Is the Session object from Python's Requests library thread safe?
  • Python Regex: Finding First and Last Names
  • Order by selection in List view of OpenERP 7.0
  • Reading input values in ipython notebook
  • List of dictionaries - how to read a specific value in a dictionary
  • writing os.system output to file
  • Create dictionary from points list and multiple attribute lists
  • How to write a table line by line with for loop
  • Map projection and forced interpolation
  • Django FBV's "render_to_response" equivalent in Class-Based-View?
  • Paramiko raises "SFTPError: Garbage packet received"
  • python pandas operations on columns
  • python list appending is not working
  • Speeding up matplotlib scatter plots
  • For each element of the list find closest date from a different list
  • How to prepend new rows at the beginning of an existing csv file?
  • how to make database robust to process kills with sqlite postgress and sqlalchemy?
  • finding a set of ranges that a number fall in
  • New line in python print() function
  • How to clear os.environ value for only one Variable in Python
  • Why does python append a modulo(%) operator to the end of a newly opened file?
  • recursive function or non-recursive that doesnt use 2 ** approach
  • Extract floats from a String using regular expression
  • How to solve: ImportError: No module named django.core.wsgi in Apache2 log?
  • What's the most concise way to include multiple statements in a Python switch case?
  • python xml pretty print not working
  • Can we use NumPy in writing a website?
  • Called bashscript doesn't start up GNU screen session
  • Reading fortran direct access data and writing formatted data - faster with python than with fortran?
  • Language supporting nested definition of functions
  • Find elements which exists in the most of the lists
  • Templating library in node.js similar to Jinja2 in Python?
  • Python Syntax Error, 'break' is outside the loop
  • Replacing spaces with hyphens
  • How to open a csv file in Microsoft Excel in Python?
  • ModuleNotFoundError: No module named 'users'
  • shadow
    Privacy Policy - Terms - Contact Us © ourworld-yourmove.org