This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from scrapy.spiders import CrawlSpider, Rule | |
| class SuperSpider(CrawlSpider): | |
| name = 'follower' | |
| allowed_domains = ['en.wikipedia.org'] | |
| start_urls = ['https://en.wikipedia.org/wiki/Web_scraping'] | |
| base_url = 'https://en.wikipedia.org' | |
| custom_settings = { | |
| 'DEPTH_LIMIT': 1 | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| sns.lineplot(x = "month", y = "log_requests_total", hue='category', data=pivot_status) | |
| plt.show() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| URL = 'https://www.bbc.co.uk' | |
| req = requests.get(url) | |
| soup = BeautifulSoup(req.text, "html.parser") | |
| links = soup.find_all('a') | |
| df = pd.DataFrame({'links':links}) | |
| df |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| url = 'https://www.bbc.co.uk' | |
| req = requests.get(url) | |
| soup = BeautifulSoup(req.text, "html.parser") | |
| for link in soup.find_all('a'): | |
| print(link.get('href')) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from bs4 import BeautifulSoup | |
| import requests | |
| url = 'https://www.deepcrawl.com' | |
| req = requests.get(url) | |
| soup = BeautifulSoup(req.text, "html.parser") | |
| title = soup.title print(title) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| headers = {'User-Agent': 'Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)'} | |
| ua_response = requests.get('https://www.bbc.com/', headers=headers) | |
| print(ua_response) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| headers = response.headers | |
| print(headers) | |
| response.headers['Content-Type'] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| if response.status_code == 200: | |
| print('Success!') | |
| elif response.status_code == 404: | |
| print('Not Found.') |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import requests | |
| response = requests.get('https://rvth.blog') | |
| print(response) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import pandas as pd | |
| df = pd.read_csv('/Users/rutheverett/Documents/Folder/file_name.csv') | |
| df.head | |
| indexable = df[(df.indexable == True)] | |
| indexable |
NewerOlder