Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Add 6th example to chapter2
  • Loading branch information
will-i-amv authored Jun 30, 2021
commit e14730f6c403f95dc0e47a9e685adfa5fc640761
12 changes: 12 additions & 0 deletions v2/chapter2/6-regularExpressions.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
from urllib.request import urlopen
from bs4 import BeautifulSoup
import re


html = urlopen('http://www.pythonscraping.com/pages/page3.html')
bs = BeautifulSoup(html, 'html.parser')
images = bs.find_all(
'img',
{'src':re.compile('\.\.\/img\/gifts/img.*\.jpg')})
for image in images:
print(image['src'])