Comments (9)
Closing because I'm unable to reproduce this bug. For some reason it's not passing the if statement on line 37.
You could try the new PyPi release, but I don't see that fixing too much.
from tiktok-api.
Did you follow the installation guide in the readme exactly?
from tiktok-api.
Done already.. but still not working... Ok No problem.. I am Leaving this project..
from tiktok-api.
Can you provide an example of the code you’re running before you leave
from tiktok-api.
It is from example getTrending.py
from tiktok import TikTokapi
api = TikTokapi()
results = 10
trending = api.trending(results)
for tiktok in trending:
print(tiktok['musicInfos']['playUrl'][0])
print(tiktok['itemInfos']['text'])
print(len(trending))
from tiktok-api.
tiktok.py
class TikTokapi:
def __init__(self):
print("New class reference, finding valid signature. This might take a minute.")
from browsermobproxy import Server
import psutil
import json
import time
for proc in psutil.process_iter():
# check whether the process name matches
if proc.name() == "browsermob-proxy":
proc.kill()
dict = {'port': 8090}
server = Server(
path="C:/Users/Sagar/Downloads/TikTok-Api-master/browsermob-proxy/bin/browsermob-proxy", options={'port': 9090})
server.start()
time.sleep(1)
proxy = server.create_proxy()
time.sleep(1)
from selenium import webdriver
profile = webdriver.FirefoxProfile()
selenium_proxy = proxy.selenium_proxy()
profile.set_proxy(selenium_proxy)
# driver = webdriver.Firefox(firefox_profile=profile)
driver = webdriver.Firefox(executable_path = 'C:/Users/Sagar/AppData/Local/Programs/Python/Python37-32/geckodriver/geckodriver.exe')
proxy.new_har("list")
driver.get("https://www.tiktok.com/en/trending")
data = proxy.har
for element in data['log']['entries']:
if "https: //www.tiktok.com/share/item/list?" in element['request']['url'] or "https://www.tiktok.com/share/item/list?" in element['request']['url']:
print("Found signature, continuing.")
self.signature = element['request']['queryString'][6]['value']
server.stop()
driver.quit()
def trending(self, count=10, verbose=0):
import requests
while True:
url = "https://m.tiktok.com/share/item/list?id=&type=5&count=" + \
str(count) + "&minCursor=0&maxCursor=0&_signature=" + \
self.signature
r = requests.get(url, headers={"authority": "m.tiktok.com", "method": "GET", "path": url.split("https://m.tiktok.com")[0], "scheme": "https", "accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3",
"accept-encoding": "gzip, deflate, br", "accept-language": "en-US,en;q=0.9", "cache-control": "max-age=0", "upgrade-insecure-requests": "1",
"user-agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/74.0.3729.169 Safari/537.36"})
data = r.json()
response = []
if data["statusCode"] != 0:
if verbose == 1:
print("Invalid Signature Retrying")
else:
for tiktok in data["body"]["itemListData"]:
response.append(tiktok)
while True:
if count > len(response) and str(data['body']['hasMore']) == "True":
url = "https://m.tiktok.com/share/item/list?id=&type=5&count=" + \
str(count - len(response)) + "&minCursor=0&maxCursor=" + \
data['body']['maxCursor'] + \
"&_signature=" + self.signature
r = requests.get(url, headers={"authority": "m.tiktok.com", "method": "GET", "path": url.split("https://m.tiktok.com")[0], "scheme": "https", "accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3",
"accept-encoding": "gzip, deflate, br", "accept-language": "en-US,en;q=0.9", "cache-control": "max-age=0", "upgrade-insecure-requests": "1",
"user-agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/74.0.3729.169 Safari/537.36"})
data = r.json()
for tiktok in data["body"]["itemListData"]:
response.append(tiktok)
else:
return response
def userPosts(self, id, count=10, verbose=0):
import requests
while True:
url = "https://m.tiktok.com/share/item/list?id=" + str(id) + "&type=1&count=" + \
str(count) + "&minCursor=0&maxCursor=0&_signature=" + \
self.signature
r = requests.get(url, headers={"authority": "m.tiktok.com", "method": "GET", "path": url.split("https://m.tiktok.com")[0], "scheme": "https", "accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3",
"accept-encoding": "gzip, deflate, br", "accept-language": "en-US,en;q=0.9", "cache-control": "max-age=0", "upgrade-insecure-requests": "1",
"user-agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/74.0.3729.169 Safari/537.36"})
data = r.json()
response = []
if data["statusCode"] != 0:
if verbose == 1:
print("Invalid Signature Retrying")
else:
for tiktok in data["body"]["itemListData"]:
response.append(tiktok)
while True:
if count > len(response) and str(data['body']['hasMore']) == "True":
url = "https://m.tiktok.com/share/item/list?id=" + str(id) + "&type=1&count=" + \
str(count - len(response)) + "&minCursor=0&maxCursor=" + data['body']['maxCursor'] + "&_signature=" + \
self.signature
var = True
while var:
r = requests.get(url, headers={"authority": "m.tiktok.com", "method": "GET", "path": url.split("https://m.tiktok.com")[0], "scheme": "https", "accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3",
"accept-encoding": "gzip, deflate, br", "accept-language": "en-US,en;q=0.9", "cache-control": "max-age=0", "upgrade-insecure-requests": "1",
"user-agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/74.0.3729.169 Safari/537.36"})
data = r.json()
if data["statusCode"] == 0:
for tiktok in data["body"]["itemListData"]:
response.append(tiktok)
var = False
else:
if verbose == 1:
print("Invalid Signature Retrying")
else:
return response
from tiktok-api.
Just updated the code. See if that fixed the issue.
from tiktok-api.
Thanku For Your Time... But Error didn't changed.
Traceback (most recent call last):
File "getTrending.py", line 11, in
trending = api.trending(results)
File "C:\Users\Sagar\Downloads\TikTok-Api-master\tiktok.py", line 46, in trend
ing
self.signature
AttributeError: 'TikTokapi' object has no attribute 'signature'
from tiktok-api.
I am also getting this error with python 3.7.3 on my Macbook, recently updated with pip3.
MacBook-Pro:tiktok3 hackmoore$ python3 demo1.py New class reference, finding valid signature. This might take a minute. Traceback (most recent call last): File "demo1.py", line 5, in <module> print( api.trending(10) ) File "/usr/local/lib/python3.7/site-packages/TikTokApi/tiktok.py", line 246, in trending self.signature AttributeError: 'TikTokapi' object has no attribute 'signature'
Firefox opens correctly, it opens the trending page and the closes as expected then this error pops up.
Code for demo1.py is:
import TikTokApi api = TikTokApi.TikTokapi('browsermob-proxy-2.1.4/bin/browsermob-proxy') print( api.trending(10) )
from tiktok-api.
Related Issues (20)
- Getting more video ids than 30 fails HOT 14
- I got error " Failed to get msToken from cookies" HOT 2
- [BUG] - Empty userInfo for small accounts HOT 1
- Videos generated in the last 24 hours for a specific word
- Any function returns permanently empty fields HOT 7
- Is this repo available now?
- music have 40k videos but scrab only 4k videos HOT 3
- [FEATURE_REQUEST] - What you want here
- [INSTALLATION] - Change the region of content HOT 8
- [BUG] - Your Error Here HOT 2
- Issue with User HOT 2
- Legal Implications of Using TikTok Data for Insights as Per Its Terms of Service
- [FEATURE_REQUEST] - Regarding creating a session
- [BUG] - cannot import name 'TikTokApi' from 'TikTokApi' HOT 1
- [QUESTION] - How to use proxies to get anothor region TikToks? HOT 5
- Not able to fetch more than 10 users for a particular keyword
- How to deploy TikTokApi script? HOT 1
- Getting EmptyResponseException HOT 3
- Data from the past HOT 2
- [FEATURE_REQUEST] - Get more infos on users ans geography
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from tiktok-api.