Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to web scrape this?
#4
(May-27-2021, 10:24 PM)Pedroski55 Wrote: So I thought, "I'll webscrape it and save the text!", just as practice.

But, there is no .html or .php just:
Do you see .html or .php often as it's not common to have in a url address.
So on the web dos not filename extensions matter,
as web-server call .html files and map it to a serve name and browser also communicated with a name server(DNS) to translate the server name.
Read more about this.

So scraping it's the same way as it's just normal url address.
import requests
from bs4 import BeautifulSoup

url = 'https://www.geeksforgeeks.org/difference-between-propositional-logic-and-predicate-logic/'
response = requests.get(url)
soup = BeautifulSoup(response.content, 'lxml')
print(soup.select_one('div.title').text)
print(soup.select_one('#post-564612 > div.text > ol:nth-child(4) > li:nth-child(1)').text)
Output:
Difference between Propositional Logic and Predicate Logic If x is real, then x2 > 0
Pedroski55 likes this post
Reply


Messages In This Thread
How to web scrape this? - by Pedroski55 - May-27-2021, 10:24 PM
RE: How to web scrape this? - by Larz60+ - May-27-2021, 10:39 PM
RE: How to web scrape this? - by Pedroski55 - May-28-2021, 12:43 AM
RE: How to web scrape this? - by snippsat - May-28-2021, 12:57 AM
RE: How to web scrape this? - by Pedroski55 - May-28-2021, 07:07 AM
RE: How to web scrape this? - by Larz60+ - May-28-2021, 09:50 AM
RE: How to web scrape this? - by snippsat - May-28-2021, 10:17 AM
RE: How to web scrape this? - by nilamo - May-28-2021, 07:18 PM

Forum Jump:

User Panel Messages

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