This file contains 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
REM This is a comment | |
cd instabot-master/examples | |
like_hashtags_copy.py neonphotography | |
ECHO Ran first batch | |
PAUSE |
This file contains 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
#!/bin/sh | |
Python /Users/yanissilloul/Documents/instabot-master/examples/like_hashtags_copy.py neonphotography |
This file contains 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 | |
from bs4 import BeautifulSoup |
This file contains 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 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2228.0 Safari/537.36'} |
This file contains 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.apple.com/shop/buy-mac/macbook" |
This file contains 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
# First we "get" the URL using requests | |
request = requests.get(url, headers=headers) | |
# Then we retrieve the content | |
content = request.content | |
# Finally, we give this content to BeautifulSoup |
This file contains 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
find_tag = soup.find(attrs={"class" : "as-macbundle-modelvariationtitle"}) | |
print(find_tag) | |
# >>> <h3 class="as-macbundle-modelvariationtitle">1.2GHz Processor<br/> 256GB Storage</h3> | |
# This code finds the first HTML tag that has a class named "as-macbundle-modelvariationtitle" | |
find_text = find_tag.text |
This file contains 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
# First way is to follow the same exact way of doing than before : | |
price_tag = soup.find(attrs={"class" : "as-price-currentprice"}) | |
price_text = price_tag.text | |
print(price_text) | |
# The second way is to not look for the class of the tag but for its other attribute : |
This file contains 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
price = soup.find(attrs={"class" : "as-price-currentprice"}).text.strip() | |
print(price) | |
# >>> $1,299.00 |
This file contains 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
# So there you have it, the product name and its price : | |
product_name = soup.find(attrs={"class" : "as-macbundle-modelvariationtitle"}).text.strip() | |
product_price = soup.find(attrs={"class" : "as-price-currentprice"}).text.strip() | |
print(f"The product '{product_name}' is sold at '{product_price}'") | |
# >>> The product '1.2GHz Processor 256GB Storage' is sold at '$1,299.00' |
OlderNewer