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 499093
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T05:57:01+00:00 2026-05-13T05:57:01+00:00

Working code: Google dictionary lookup via python and beautiful soup -> simply execute and

  • 0

Working code: Google dictionary lookup via python and beautiful soup -> simply execute and enter a word.

I’ve quite simply extracted the first definition from a specific list item. However to get plain data, I’ve had to split my data at the line break, and then strip it to remove the superfluous list tag.

My question is, is there a method to extract the data contained within a specific list without doing my above string manipulation – perhaps a function in beautiful soup that I have yet to see?

This is the relevant section of code:

# Retrieve HTML and parse with BeautifulSoup.
    doc = userAgentSwitcher().open(queryURL).read()
    soup = BeautifulSoup(doc)

# Extract the first list item -> and encode it.
    definition = soup('li', limit=2)[0].encode('utf-8')

# Format the return as word:definition removing superfluous data.
    print word + " : " + definition.split("<br />")[0].strip("<li>")
  • 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-13T05:57:01+00:00Added an answer on May 13, 2026 at 5:57 am

    I think you are looking for findAll(text=True) this will extract the text from the tags

    definitions = soup('ul')[0].findAll(text=True)
    

    Will return a ist of all the text contents broken at the tag boundaries

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 513k
  • Answers 513k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer FreeResource on MSDN says no. The function was used in… May 16, 2026 at 5:56 pm
  • Editorial Team
    Editorial Team added an answer Your build script phase has access to the full set… May 16, 2026 at 5:56 pm
  • Editorial Team
    Editorial Team added an answer In order to prevent problems when your variable contians someting… May 16, 2026 at 5:56 pm

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Related Questions

I am working with google map api ... http://code.google.com/p/gmaps-samples-flash/source/browse/trunk/samplecode/GeocodingSimple.mxml What i want to do
I'm working with google annotated time line graphs: http://code.google.com/apis/visualization/documentation/gallery/annotatedtimeline.html My question is: I would
I'm working with the EXIF library at http://code.google.com/p/iphone-exif/ and I have come across a
There’s a really cool diff class hosted by Google here: http://code.google.com/p/google-diff-match-patch/ I’ve used it
I am using http://code.google.com/p/solr-php-client/ to communicate with the solr from PHP. Every thing is
I had some sample code I was working on and broke the link to
I am working on a project in javascript involving google maps. The goal is
Response To: Opening Popup Window is not working in firefox and google chrome Hi,I
I have a specialized string dictionary of (string, string) (_RulesAndTheirDescriptions) that contains the name
At the moment I am working on an on screen display project with black,

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.