You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
i have optimized the automatic way to get user agent, and cookie with selenium, and used it to optimize the download, and it worked.
however i can't download all videos in 1 channel, can anyone help me, thank you
def get_browser_data():
"""Function to retrieve cookies and user-agent from the browser"""
try:
chrome_options = Options()
chrome_options.add_argument('--headless')
driver = webdriver.Chrome(options=chrome_options)
driver.get('https://www.xiaohongshu.com')
# Retrieve cookies
cookies = driver.get_cookies()
cookie_string = "; ".join([f"{cookie['name']}={cookie['value']}" for cookie in cookies])
# Retrieve user agent
user_agent = driver.execute_script("return navigator.userAgent")
driver.quit()
print("Successfully retrieved cookies and user-agent")
return cookie_string, user_agent
except Exception as e:
print(f"Error while retrieving browser data: {e}")
return None, None
async def app():
"""Run the application with automatically obtained cookies and user-agent"""
# Retrieve cookies and user-agent
cookie, user_agent = get_browser_data()
# Update the settings file
settings = Settings(ROOT) # Create a new instance of Settings
current_settings = settings.run() # Retrieve the current settings
current_settings.update({
'cookie': cookie,
'user_agent': user_agent
})
settings.update(current_settings) # Update the settings file
# Initialize XHSDownloader
async with XHSDownloader() as xhs:
await xhs.run_async()
The text was updated successfully, but these errors were encountered:
To my understanding, XHS doesn't send all the video information to the client's web browser upon visit, and you might need a way to mimic the mouse scroll movement to retrieve more video links. I am not sure if this is the problem you are facing, but that's my understanding on why you can't download all the videos.
i have optimized the automatic way to get user agent, and cookie with selenium, and used it to optimize the download, and it worked.
however i can't download all videos in 1 channel, can anyone help me, thank you
def get_browser_data():
"""Function to retrieve cookies and user-agent from the browser"""
try:
chrome_options = Options()
chrome_options.add_argument('--headless')
async def app():
"""Run the application with automatically obtained cookies and user-agent"""
# Retrieve cookies and user-agent
cookie, user_agent = get_browser_data()
The text was updated successfully, but these errors were encountered: