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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T05:23:37+00:00 2026-06-18T05:23:37+00:00

I have the following html pattern I want to scrap using BeautifulSoup. The html

  • 0

I have the following html pattern I want to scrap using BeautifulSoup. The html pattern is:

<a href="link" target="_blank" onclick="blah blah blah">TITLE</a>

I want to grab TITLE and the information that is displayed in the link. That is, if you clicked the link there is a a description of the TITLE. I want that description.

I started with just trying to grab the title with the following code:

import urllib
from bs4 import BeautifulSoup
import re

webpage = urrlib.urlopen("http://urlofinterest")

title = re.compile('<a>(.*)</a>')
findTitle = re.findall(title,webpage)
print findTile

My output is:

% python beta2.py
[]

So this is obviously not even finding the title. I even tried <a href>(.*)</a> and that didn’t work. Based on my reading of the documentation and I thought BeautifulSoup will grab whatever text is between the symbols I give it. In this case, , so what am I doing wrong?

  • 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-18T05:23:38+00:00Added an answer on June 18, 2026 at 5:23 am

    How come you’re importing beautifulsoup and then not using it at all?

    webpage = urrlib.urlopen("http://urlofinterest")
    

    You’ll want to read the data from this, so that:

    webpage = urrlib.urlopen("http://urlofinterest").read()
    

    Something like (should get you to a point to go further):

    >>> blah = '<a href="link" target="_blank" onclick="blah blah blah">TITLE</a>'
    >>> from bs4 import BeautifulSoup
    >>> soup = BeautifulSoup(blah) # change to webpage later
    >>> for tag in soup('a', href=True):
        print tag['href'], tag.string
    
    link TITLE
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following html : <div class=mainmenu> <ul class=blue> <li class=><a href=tst/ id=a1_up><span
I have following html: <td class=section> <div style=margin-top:2px; margin-bottom:-10px; > <span class=username><a href=user.php?id=xx>xxUsername</a></span> </div>
In my web.xml I have the following mapping <servlet-mapping> <servlet-name>mySite</servlet-name> <url-pattern>*.html</url-pattern> </servlet-mapping> <servlet-mapping> <servlet-name>mySite</servlet-name>
I have this string with HTML inside: <span title=whatever>something I want to preserve</span>... I'm
i have the following html in my view <span style=float:right> <label> Pattern :</label> <select>
I'm using the following code (with the Underscore.js library) to add the attributes target=_blank
Suppose you have this following code in HTML - <div id=pattern> <span class=a>Content</span> </div>
i have a following pattern, inside the html file, that i would like to
Let me explain what I want. I have the following (partial) HTML. <ul> <li
I have the following code private String anchorRegex = \\<\\s*?a\\s+.*?href\\s*?=\\s*?([^\\s]*?).*?\\>; private Pattern anchorPattern =

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.