Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Web Scraping on href text
#3
Thank you
I wrote this code:
from urllib.request import urlopen
from bs4 import BeautifulSoup
import re

html = urlopen('http://www.orchidspecies.com/indexe-ep.htm')
bs = BeautifulSoup(html, 'html.parser')
images = bs.find_all('a')
for image in images: 
  prova=image.text
  if re.search('Earina sigmoidea', prova):
    #print(image.text)
    print(image.get('href')) 
But the result is not entirely correct, becouse the name 'Earina sigmoidea' in the page there is only one.
Why this ?

this is the result.
Output:
earinaaestivalis.htm earsigmoidea.htm
Reply


Messages In This Thread
Web Scraping on href text - by Superzaffo - Nov-13-2019, 10:32 PM
RE: Web Scraping on href text - by Larz60+ - Nov-14-2019, 12:30 AM
RE: Web Scraping on href text - by Superzaffo - Nov-14-2019, 09:06 AM
RE: Web Scraping on href text - by Malt - Nov-14-2019, 10:27 AM
RE: Web Scraping on href text - by Larz60+ - Nov-14-2019, 10:54 AM
RE: Web Scraping on href text - by Superzaffo - Nov-14-2019, 08:20 PM
RE: Web Scraping on href text - by Superzaffo - Nov-14-2019, 10:05 PM
RE: Web Scraping on href text - by Larz60+ - Nov-15-2019, 02:33 AM
RE: Web Scraping on href text - by Superzaffo - Nov-15-2019, 08:10 AM
RE: Web Scraping on href text - by Larz60+ - Nov-15-2019, 12:43 PM
RE: Web Scraping on href text - by Superzaffo - Nov-15-2019, 01:18 PM
RE: Web Scraping on href text - by Superzaffo - Nov-16-2019, 10:52 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Extract Href URL and Text From List knight2000 2 9,360 Jul-08-2021, 12:53 PM
Last Post: knight2000
  BeautifulSoup pagination using href rhat398 1 2,456 Jun-30-2021, 10:55 AM
Last Post: snippsat
  Accessing a data-phone tag from an href KatMac 1 2,934 Apr-27-2021, 06:18 PM
Last Post: buran
  Scraping all website text using Python MKMKMKMK 1 2,122 Nov-26-2020, 10:35 PM
Last Post: Larz60+
  Scraping text from application? kamix 1 1,650 Sep-25-2020, 10:53 PM
Last Post: Larz60+
  How to get the href value of a specific word in the html code julio2000 2 3,263 Mar-05-2020, 07:50 PM
Last Post: julio2000
  scraping in a text/javascript saasyp 1 2,259 Aug-31-2019, 11:39 AM
Last Post: metulburr
  Scrapy Picking What to Output Href or Img soothsayerpg 1 2,740 Aug-02-2018, 10:59 AM
Last Post: soothsayerpg
  Flask - Opening second page via href is failing - This site can’t be reached rafiPython1 2 5,536 Apr-11-2018, 08:41 AM
Last Post: rafiPython1

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020