Skip to content

Commit 27f62e8

Browse files
modified Web Scraping with BeautifulSoup.py
added code for extracting href(links) content from page or soup object and added code for extracting images as hyperlink
1 parent f75f1f7 commit 27f62e8

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

Web Scraping with BeautifulSoup.py

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,14 @@
4141
# here i extarcted href data from anchor tag.
4242
print(links['href'])
4343

44+
## or another way
45+
##extracting href(links) attribute and anchor(<a>) tag from page
46+
for a in soup.find_all('a', href=True):
47+
print ( a['href'])
48+
49+
for i in links:
50+
print(i.text)
51+
4452
# similarly i got class details from a anchor tag
4553
print(links['class'])
4654

@@ -92,5 +100,10 @@
92100
overview=soup.find_all('table',class_='infobox vevent')
93101
for z in overview:
94102
print(z.text)
95-
103+
104+
images=soup.find_all('img')
105+
106+
images
107+
##or
108+
print(images)
96109

0 commit comments

Comments
 (0)