예제 #1
0
 def test_from_soup(self, get_request, page_instance):
     post_html = get_request.text
     post_soup = BeautifulSoup(post_html, features='lxml')
     post_obj = Post(post_soup)
     post_obj.scrape()
     assert post_obj.likes == page_instance.likes
예제 #2
0
 def test_from_html(self, get_request, page_instance):
     post_html = get_request.text
     post_obj = Post(post_html)
     post_obj.scrape()
     assert post_obj.likes == page_instance.likes
예제 #3
0
 def page_instance(self, url, headers):
     random_google_post = Post(url)
     random_google_post.scrape(headers=headers)
     return random_google_post
예제 #4
0
import parser_libraries
from selenium import webdriver
from selenium.webdriver import Chrome
from instascrape import Profile, scrape_posts, Post, Hashtag
import time

headers = {"user-agent": "Chrome/87.0.4389.23", "cookie": "sessionid= "}

f = open('input_data.txt', 'r')
posts_codes = []

for line in f:
    line = line.split(':')[1]
    line = line.split('-')
    if (len(line) == 4):
        line = line[0].strip(' ')
    else:
        line = line[0].strip(' ') + '-' + line[1].strip(' ')
    posts_codes.append(line)

print(posts_codes)
nafnaf = Profile('nafnafcol')
nafnaf.scrape(headers=headers)

for i in range(len(posts_codes)):
    nafnaf_post = Post(posts_codes[i])
    nafnaf_post.scrape()
    print('----------------------')
    print(nafnaf_post.to_dict()['caption'])
    time.sleep(10)
예제 #5
0
 def page_instance(self, url):
     random_google_post = Post(url)
     random_google_post.scrape()
     return random_google_post