소스 검색

Refactoring scraper.py: Adding method for retrieving HTML content

David Leonard 10 년 전
부모
커밋
724f3988ce
1개의 변경된 파일16개의 추가작업 그리고 0개의 파일을 삭제
  1. 16 0
      hackathon_starter/hackathon/scripts/scraper.py

+ 16 - 0
hackathon_starter/hackathon/scripts/scraper.py

@@ -7,6 +7,22 @@ import requests
 import itertools 
 from bs4 import BeautifulSoup
 
+def fetchHTML(url):
+	'''
+	Returns HTML retrived from a url.
+
+	Parameters:
+		url: String
+			- The URL to fetch HTML from
+
+	Returns:
+		html: String
+			- The HTML from a given URL
+	'''
+	req = requests.get(url)
+	html = req.text
+	return html
+
 def steamDiscounts():
 	req = requests.get('http://store.steampowered.com/search/?specials=1#sort_by=_ASC&sort_order=ASC&specials=1&page=1')
 	content = req.text