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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T08:39:57+00:00 2026-05-29T08:39:57+00:00

I am logging into a site, making a search query and then filtering the

  • 0

I am logging into a site, making a search query and then filtering the results with beautifulsoup to get all the terms in the “b” tag. From the results I’d like to check whether the search term (Testing) is present. My current code is below. The problem I am having is that even when there is a result and the term is present I still get a not present response. I have printed the filtered query and read through it and the result is definitely there so the error is in the searching part. I think the problem is that in the html the word testing isn’t by itself so its Testing.example or Testing.test and so the search can’t find it by it self surrounded by spaces. How do I search for a word/phrase within a longer word/phrase.

I need “Testing” to be found in “example.Testing.example” or in “test.Testing.example”

Hope that makes sense.

Thanks

words = ["Testing"]
br.open ('http://www.example.com/browse.php?psec=2&search=%s' % words)
html = br.response().read()
soup = BeautifulSoup(html)
filtered = soup.findAll('b')

# print filtered

for word in words:
    if word in filtered:
        print "%s found." % word
    else:
        print "%s not found." % word

Edit

[<b><a title="Unknown">---</a></b>, <b>Welcome Back<br /><a href="/user/"><
span style="color:#0080FF;"></span></a>!<br /></b>, <b><span class="smallfo
nt"><a href="/messages.php?action=viewmailbox"><img height="14px" style="border:
none" alt="inbox" title="inbox (no new messages)" src="/pic/pn_inbox.gif" /></a>
59 (0 New)</span></b>, <b><span class="smallfont">&nbsp;&nbsp;<a href="/message
s.php?action=viewmailbox&amp;box=-1"><img height="14px" style="border:none" alt=
"sentbox" title="sentbox" src="/pic/pn_sentbox.gif" /></a> 37</span></b>, <b>Sho
w all</b>, <b><< Prev</b>, <b>Next >></b>, <b>1&nbsp;-&nbsp;7</b>, **<b>The.Testing
.example.T3Z6.L</b>**, <b><span style="color:#FF5500;">dgHn</span
></b>, <b><a href="/details.php?id=15829&amp;hit=1&amp;filelist=1">1</a></b>, <b
><a href="/details.php?id=15829&amp;hit=1&amp;=1"><font>30</font></a></
b>, <b><a href="/details.php?id=15829&amp;hit=1&amp;todlers=1">1</a></b>,

When I print filtered I get the above result. Its slightly longer but you get the idea. Five lines from the bottom in **s you see the result that should case a positive but isn’t.

  • 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-29T08:39:58+00:00Added an answer on May 29, 2026 at 8:39 am

    I believe you want something more like the following

    words = ["Testing"]
    br.open ('http://www.example.com/browse.php?psec=2&search=%s' % words)
    html = br.response().read()
    soup = BeautifulSoup(html)
    filtered = soup.findAll('b')
    """element.contents[0] gives you the  first element inside the <b> tags
    If you want some other part of inside the b tag see  
    BeatifulSoup documentation at the line below """
    filteredcontents = [element.contents[0] for element in filtered]
    
    for word in words:
        if any(word in filteredcontent for filteredcontent in filteredcontents):
            print "%s found." % word
        else:
            print "%s not found." % word
    

    BeatifulSoup Documentation is available
    here

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

Sidebar

Related Questions

I'm logging into a site and then searching the site. From the results I'm
I'm building a website where I will have users logging into the site from
This is what my browser sent, when logging into some site: POST http://www.some.site/login.php HTTP/1.0
I'm having trouble logging into a secure site with a WatiN LogonDialogHandler running on
I'm writing a script in Python 3.1.2 that logs into a site and then
Is there a way to test logging into a site with open id using
I am running into an issue with logging into an ASP.NET MVC web site
Logging into a site I'm working on functions as expected on my local machine
I've recently started having trouble logging into my site using Facebook. I keep seeing
Basically, I'm trying to log into a site. I've got it logging in, but

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.