Skip to content
Open
Changes from all commits
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
4 changes: 3 additions & 1 deletion genre-scraper.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,10 @@
def get_painting_list(count, typep, searchword):
try:
time.sleep(3.0*random.random()) # random sleep to decrease concurrence of requests
hdr = {'User-Agent' : 'Mozilla/5.0 (Windows NT 6.1; Win64; x64)'}
url = "https://www.wikiart.org/en/paintings-by-%s/%s/%d"%(typep, searchword, count)
soup = BeautifulSoup(urllib.request.urlopen(url), "lxml")
req = urllib.request.Request(url, headers=hdr)
soup = BeautifulSoup(urllib.request.urlopen(req), "lxml")
regex = r'https?://uploads[0-9]+[^/\s]+/\S+\.jpg'
url_list = re.findall(regex, str(soup.html()))
count += len(url_list)
Expand Down