Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7853025
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T19:33:45+00:00 2026-06-02T19:33:45+00:00

I am trying to read a website using the urllib2 library. Here is my

  • 0

I am trying to read a website using the urllib2 library.
Here is my script:

import urllib2

# Get a file-like object for the Python Web site's home page.

def wikitranslate(word):
    translation = ''
    pageURL = ''
    opener = urllib2.build_opener()
    f = opener.open("http://fr.wikipedia.org/w/api.php?action=opensearch&search=" + re.sub(' ', '%20', word.rstrip()))
    # Read from the object, storing the page's contents in 's'.
    s = f.read()

I am wondering how the server receives these requests and if it can recognize the fact that it is accessed by a python script rather than through a browser.

If so, is there a way to hide it?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T19:33:47+00:00Added an answer on June 2, 2026 at 7:33 pm

    The User-Agent field in the header of a url request describes to the web server what browser and system you are using to access the site so the best way to either conceal or identify yourself as a python script request is to change that field.

    request = urllib2.Request(url,None)
    request.add_header('User-Agent','Python Script') # Or 'Not a python script'
    

    by default this field is left blank when using urllib2

    So if you want to conceal your agent simply do not declare it, or you can forcefully declare it to be something deceitful

    request.add_header('User-Agent','None of your business.')
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to read a TIFF image from file using BufferedImage. The following is
I'm trying to read a text file (Using BufferedReader and FileReader) from my file
I'm trying to scrape some data off of the FEC.gov website using python for
I am trying to run a website using Python 2.7.1, Jinja 2.5.2, and CherryPy
I am trying to write a C++ program to read from a website using
I am trying to read a website using the java.net package classes. The site
I have a JSON file here: http://dalexl.webs.com/products.json I'm trying to read it on my
I'm trying to parse a website's source to extract text inside using lxml library.
I am trying to build a website where I can read the data from
Trying to read an RSS and select information using Linq but can't seem to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.