Exemplo n.º 1
0
    def test_no_user_found(self):
        in_found = User()
        in_found.username="******"
        in_found.exists = False
        in_found.save()

        response = self.client.get('/twitter/adabalubaba')
        assert response.status_code == 404
Exemplo n.º 2
0
def scrape_twitter(user_name):
    user = User()
    user.username = user_name
    url_request = 'https://twitter.com/' + str(user_name)
    response = requests.get(url_request)
    if response.status_code == 200:
        soup = BeautifulSoup(response.text, "html.parser")

        data = soup.find("input", attrs={"class": "json-data"})
        data = json.loads(data["value"])
        profile_data = data["profile_user"]
        user.name = profile_data["name"]
        user.bio = profile_data["description"]
        user.location = profile_data["location"]
        user.exists = True
        time = datetime.now()
        user.query_date = time.strftime('%m/%d/%Y %I:%M%p')

        user.save()
Exemplo n.º 3
0
    def test_no_user_found(self):
        in_found = User()
        in_found.username = "******"
        in_found.exists = False
        in_found.save()

        response = self.client.get('/twitter/adabalubaba')
        assert response.status_code == 404
Exemplo n.º 4
0
def scrape_twitter(user_name):
    user = User()
    user.username = user_name
    url_request = 'https://twitter.com/' + str(user_name)
    response = requests.get(url_request)
    if response.status_code == 200:
        soup = BeautifulSoup(response.text, "html.parser")

        data = soup.find("input", attrs={"class":"json-data"})
        data = json.loads(data["value"])
        profile_data = data["profile_user"]
        user.name = profile_data["name"]
        user.bio = profile_data["description"]
        user.location = profile_data["location"]
        user.exists = True
        time = datetime.now()
        user.query_date = time.strftime('%m/%d/%Y %I:%M%p')

        user.save()