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

  • Home
  • SEARCH
  • 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 6899347
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T07:24:38+00:00 2026-05-27T07:24:38+00:00

My python level is Novice. I have never written a web scraper or crawler.

  • 0

My python level is Novice. I have never written a web scraper or crawler. I have written a python code to connect to an api and extract the data that I want. But for some the extracted data I want to get the gender of the author. I found this web site http://bookblog.net/gender/genie.php but downside is there isn’t an api available. I was wondering how to write a python to submit data to the form in the page and extract the return data. It would be a great help if I could get some guidance on this.

This is the form dom:

<form action="analysis.php" method="POST">
<textarea cols="75" rows="13" name="text"></textarea>
<div class="copyright">(NOTE: The genie works best on texts of more than 500 words.)</div>
<p>
<b>Genre:</b>
<input type="radio" value="fiction" name="genre">
fiction&nbsp;&nbsp;
<input type="radio" value="nonfiction" name="genre">
nonfiction&nbsp;&nbsp;
<input type="radio" value="blog" name="genre">
blog entry
</p>
<p>
</form>

results page dom:

<p>
<b>The Gender Genie thinks the author of this passage is:</b>
male!
</p>
  • 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-05-27T07:24:39+00:00Added an answer on May 27, 2026 at 7:24 am

    No need to use mechanize, just send the correct form data in a POST request.

    Also, using regular expression to parse HTML is a bad idea. You would be better off using a HTML parser like lxml.html.

    import requests
    import lxml.html as lh
    
    
    def gender_genie(text, genre):
        url = 'http://bookblog.net/gender/analysis.php'
        caption = 'The Gender Genie thinks the author of this passage is:'
    
        form_data = {
            'text': text,
            'genre': genre,
            'submit': 'submit',
        }
    
        response = requests.post(url, data=form_data)
    
        tree = lh.document_fromstring(response.content)
    
        return tree.xpath("//b[text()=$caption]", caption=caption)[0].tail.strip()
    
    
    if __name__ == '__main__':
        print gender_genie('I have a beard!', 'blog')
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a top level widget that is producing a syntax error in python.
I have heard of some compilers that convert code in one high level language
I am an intermediate level Python Programmer and I have written a Python program
I have a Python script that will be doing a lot of things that
If I have a Python module implemented as a directory (i.e. package) that has
I have a python script that creates and starts 3 threads, and then goes
Whitespace is signification in Python in that code blocks are defined by their indentation.
How is this implemented at a python level? I've got an object that pretends
I have a module-level variable in my Python 2.6 program named _log, which PyLint
I know some higher level languages, all web based (PHP, javascript, some python). I've

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.