Nov-15-2019, 01:18 PM
Ok. No problem.
I'm in no hurry.
Thank you
:-D
I'm in no hurry.
Thank you
:-D
|
Web Scraping on href text
|
|
Nov-15-2019, 01:18 PM
Ok. No problem.
I'm in no hurry. Thank you :-D
Nov-16-2019, 10:52 AM
(This post was last modified: Nov-16-2019, 10:52 AM by Superzaffo.)
I wrote this code.. From our exaple (Thank you)
from bs4 import BeautifulSoup
import requests
class ScrapeOrchids:
def __init__(self):
self.main_url = 'http://www.orchidspecies.com/indexe-ep.htm'
self.links = {}
self.get_initial_list()
self.show_links()
def get_initial_list(self):
baseurl = 'http://www.orchidspecies.com/'
response = requests.get(self.main_url)
if response.status_code == 200:
page = response.content
soup = BeautifulSoup(page, 'lxml')
# css_select link can be found using browser inspect element, then right click-->Copy-->CSS_Selector
for i in soup.select("li"):
#print(i.a.text)
if 'Epiblastus lancipetalus' in i.a.text:
#print(i.a.get('href'))
self.links[i.a.text.strip()] = f"{baseurl}{i.a.get('href')}"
else:
print(f"Problem fetching {self.main_url}")
def show_links(self):
for key, value in self.links.items():
print(f"{key}: {value}")
if __name__ == '__main__':
ScrapeOrchids()this is the result and is what I want.Now I need to get the new link and in the page save the image of the orchid in a excel file. :-( |
|
|
| Possibly Related Threads… | |||||
| Thread | Author | Replies | Views | Last Post | |
| Extract Href URL and Text From List | knight2000 | 2 | 29,119 |
Jul-08-2021, 12:53 PM Last Post: knight2000 |
|
| BeautifulSoup pagination using href | rhat398 | 1 | 3,885 |
Jun-30-2021, 10:55 AM Last Post: snippsat |
|
| Accessing a data-phone tag from an href | KatMac | 1 | 4,126 |
Apr-27-2021, 06:18 PM Last Post: buran |
|
| Scraping all website text using Python | MKMKMKMK | 1 | 3,324 |
Nov-26-2020, 10:35 PM Last Post: Larz60+ |
|
| Scraping text from application? | kamix | 1 | 4,488 |
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 | 5,294 |
Mar-05-2020, 07:50 PM Last Post: julio2000 |
|
| scraping in a text/javascript | saasyp | 1 | 3,258 |
Aug-31-2019, 11:39 AM Last Post: metulburr |
|
| Scrapy Picking What to Output Href or Img | soothsayerpg | 1 | 3,733 |
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 | 7,471 |
Apr-11-2018, 08:41 AM Last Post: rafiPython1 |
|