Comments (15)
this is not the right user_div for the mostly of accounts, some accounts have different layouts.
there are two variants of user_div
//article/div[2]/div[1]/ul[1]/li[1]
and for some users
//article/div[2]/ul[1]/li[1]
I'm gonna try to find the pattern/relation between user accounts and the elements class.
from instapy.
@mateuspontes could you please try with the modifications of this gist?
from instapy.
What OS, chromedriver version and resolution are you using?
from instapy.
Ubuntu 16.04, ChromeDriver 2.29 :)
from instapy.
Invalid Page: Message: no such element: Unable to locate element: {"method":"xpath","selector":"//article/div[2]/div[1]/ul[1]/li[1]"}
(Session info: chrome=57.0.2987.133)
(Driver info: chromedriver=2.29.461585 (0be2cd95f834e9ee7c46bcc7cf405b483f5ae83b),platform=Mac OS X 10.12.4 x86_64)
from instapy.
Instagram has renamed attrs, I fixed using:
user_div = browser.find_element_by_xpath('//*[@id="react-root"]/section/main/div/div/article/header')
and for like
def like_image(browser):
"""Likes the browser opened image"""
like_elem = browser.find_elements_by_xpath("//span[contains(@class, 'coreSpriteHeartOpen')]")
liked_elem = browser.find_elements_by_xpath("//span[contains(@class, 'coreSpriteHeartFull')]")
from instapy.
@mateuspontes could you open this photo on chrome, open the JS Console and show me the value of window._sharedData.qe.ebd.p.use_new_styles
variable?
from instapy.
undefined
from instapy.
@mateuspontes for me it has the "true" value, did you have the window._sharedData
element in this page?
Edit: note that this variable (use_new_styles) only exists when you're logged.
Do you mind share the content (if exists) with me?
from instapy.
> window._sharedData.qe.ebd.p
Object {}
from instapy.
@mateuspontes the full element.
If you inspect the page, search for window._sharedData
, you will see the entire element.
Are you logged when you opened that link? I've noticed that the variable only exists when you're logged.
With your variable (that is different that the ones that i've got there) maybe i can get all the information needed with JS instead of getting DOM elements.
from instapy.
window._sharedData = {
"gatekeepers": {
"ld": true,
"sms": true
},
"platform": "web",
"hostname": "www.instagram.com",
"config": {
"..."
},
"entry_data": {
"PostPage": [{
"media": {
"__typename": "GraphImage",
"id": "1482867557781291065",
"dimensions": {
"height": 1080,
"width": 1080
},
"is_video": false,
"caption_is_edited": false,
"comments_disabled": false,
"edge_media_to_sponsor_user": {
"edges": []
},
"location": {
"id": "2152627",
"has_public_page": true,
"name": "Base Aerea dos Afonsos",
"slug": "base-aerea-dos-afonsos"
},
"owner": {
"id": "4029506392",
"profile_pic_url": "https://instagram.fsdu5-1.fna.fbcdn.net/t51.2885-19/s150x150/16123830_224952484579048_1913078205728686080_a.jpg",
"username": "denilson13_santos",
"followed_by_viewer": false,
"full_name": "Denilson Santos",
"is_private": true,
"requested_by_viewer": false,
"is_unpublished": false,
"blocked_by_viewer": false,
"has_blocked_viewer": false
},
"is_ad": false,
"code": "BSUNC_ugUA5F-oCjArV_iczK5DwU_TSQLFTdAE0",
"date": 1490991609,
"display_src": "https://instagram.fsdu5-1.fna.fbcdn.net/t51.2885-15/e35/17596225_1354368707956047_8836042471533182976_n.jpg",
"caption": "Sextouuu e nos aqui RS\n\n#profiss\u00e3o #Perigo \n#Paraquedista_do_Brasil \n#c130 #h\u00e9rcules\n#maisum",
"comments": {
"count": 1,
"page_info": {
"has_next_page": false,
"end_cursor": null,
"has_previous_page": false,
"start_cursor": null
},
"nodes": [{
"id": "17875551001009991",
"text": "Pqdt mant\u00e9m kkk",
"created_at": 1490994779,
"user": {
"id": "3599503429",
"profile_pic_url": "https://instagram.fsdu5-1.fna.fbcdn.net/t51.2885-19/s150x150/16123321_145189442654371_4934830132188676096_a.jpg",
"username": "alexdasilvahonorato"
}
}]
},
"likes": {
"count": 64,
"viewer_has_liked": false,
"nodes": [{
"user": {
"id": "911929392",
"profile_pic_url": "https://instagram.fsdu5-1.fna.fbcdn.net/t51.2885-19/s150x150/17661800_241235483011635_6384000880097624064_a.jpg",
"username": "blancatorijano"
}
}, {
"user": {
"id": "4514955195",
"profile_pic_url": "https://instagram.fsdu5-1.fna.fbcdn.net/t51.2885-19/s150x150/17332424_420763771593966_8379907963921367040_a.jpg",
"username": "sofiacferrero"
}
}, {
"user": {
"id": "1519981595",
"profile_pic_url": "https://instagram.fsdu5-1.fna.fbcdn.net/t51.2885-19/s150x150/17596032_1854918328062096_6646791864307417088_a.jpg",
"username": "nessamontemor"
}
}, {
"user": {
"id": "4358941472",
"profile_pic_url": "https://instagram.fsdu5-1.fna.fbcdn.net/t51.2885-19/s150x150/17076413_228650600934807_868531937319321600_a.jpg",
"username": "sexypamela1990"
}
}, {
"user": {
"id": "3236613421",
"profile_pic_url": "https://instagram.fsdu5-1.fna.fbcdn.net/t51.2885-19/s150x150/17266066_1264014380342135_3920736053786312704_a.jpg",
"username": "kallyne_oliveria.cardoso"
}
}, {
"user": {
"id": "2230445609",
"profile_pic_url": "https://instagram.fsdu5-1.fna.fbcdn.net/t51.2885-19/s150x150/17076485_102949610225267_7136854685117317120_a.jpg",
"username": "nilo.paixao"
}
}, {
"user": {
"id": "509774903",
"profile_pic_url": "https://instagram.fsdu5-1.fna.fbcdn.net/t51.2885-19/s150x150/17267824_1173888642737136_7905056736157892608_a.jpg",
"username": "nathaliaasousaa"
}
}, {
"user": {
"id": "4053355451",
"profile_pic_url": "https://instagram.fsdu5-1.fna.fbcdn.net/t51.2885-19/s150x150/17663632_973500129452882_1007902835800539136_a.jpg",
"username": "pulchritudinousxjulyxqueen"
}
}, {
"user": {
"id": "507273528",
"profile_pic_url": "https://instagram.fsdu5-1.fna.fbcdn.net/t51.2885-19/s150x150/16584067_1756846617966069_135490872270651392_a.jpg",
"username": "andrezinho_menezes"
}
}, {
"user": {
"id": "4458820476",
"profile_pic_url": "https://instagram.fsdu5-1.fna.fbcdn.net/t51.2885-19/s150x150/15875779_1199121913498816_5055891447648092160_a.jpg",
"username": "rejjane_silva"
}
}]
},
"usertags": {
"nodes": []
},
"related_media": {
"nodes": []
}
}
}]
},
"display_properties_server_guess": {
"pixel_ratio": 1.0,
"viewport_width": 1280
},
"country_code": "BR",
"activity_counts": {
"comment_likes": 0,
"comments": 0,
"likes": 0,
"relationships": 0,
"usertags": 0
},
"qe": {
"profile": {
"p": {
"take": "false"
},
"g": "take_photo_control"
},
"sidecar": {
"p": {},
"g": ""
},
"us": {
"p": {},
"g": ""
},
"us_li": {
"p": {
"show_camera_icon": "false"
},
"g": "show_camera_control_03"
},
"ebd": {
"p": {},
"g": ""
},
"gql": {
"p": {
"new_chaining_endpoint": "true"
},
"g": "test"
},
"ufi": {
"p": {},
"g": ""
},
"video": {
"p": {},
"g": ""
},
"pm": {
"p": {},
"g": ""
},
"nav_lo": {
"p": {
"logged_out_nav": "true"
},
"g": "web_nav_logged_out_test_01"
},
"deact": {
"p": {},
"g": ""
},
"ufi_loggedout": {
"p": {},
"g": ""
},
"feed": {
"p": {},
"g": ""
},
"poe": {
"..."
},
"su_universe": {
"p": {},
"g": ""
},
"nav": {
"p": {},
"g": ""
},
"create": {
"p": {},
"g": ""
}
},
"environment_switcher_visible_server_guess": true,
"show_app_install": false,
"language_code": "pt-br"
};
from instapy.
It works ;)
from instapy.
@mateuspontes process also crashes on dead link/ if post has been deleted.
[15/93]
Traceback (most recent call last):
File "./quickstart.py", line 19, in <module>
.like_by_tags(['car', '#dog'], amount=100) \
File "/home/synod/AT/cronos/InstaPy/instapy/instapy.py", line 225, in like_by_tags
self.ignore_if_contains, self.username)
File "/home/synod/AT/cronos/InstaPy/instapy/like_util.py", line 51, in check_link
user_name = browser.execute_script("return window._sharedData.entry_data.PostPage[0].media.owner.username")
File "/usr/local/lib/python2.7/dist-packages/selenium-2.53.6-py2.7.egg/selenium/webdriver/remote/webdriver.py", line 465, in execute_script
'args': converted_args})['value']
File "/usr/local/lib/python2.7/dist-packages/selenium-2.53.6-py2.7.egg/selenium/webdriver/remote/webdriver.py", line 236, in execute
self.error_handler.check_response(response)
File "/usr/local/lib/python2.7/dist-packages/selenium-2.53.6-py2.7.egg/selenium/webdriver/remote/errorhandler.py", line 192, in check_response
raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.WebDriverException: Message: unknown error: Cannot read property '0' of undefined
(Session info: chrome=57.0.2987.110)
(Driver info: chromedriver=2.29.461571 (8a88bbe0775e2a23afda0ceaf2ef7ee74e822cc5),platform=Linux 4.4.0-71-generic x86_64)
selenium.common.exceptions.WebDriverException: Message: unknown error: Cannot read property '0' of undefined
from instapy.
@ianjuma Thanks for the information, I'll open an issue for that!
from instapy.
Related Issues (20)
- I need this
- Huss
- Cookie file not found, creating cookie... HOT 3
- Login A/B test detected! Trying another string... HOT 2
- Xgjh
- ModuleNotFound error while installing HOT 1
- Connection actively refused.
- Termux error "idk help pls" HOT 1
- Problem with running instapy for the first time, please help HOT 3
- Is this project abandoned? HOT 9
- On_message_event HOT 1
- cookies expire after 20-30 request and need to re login
- TypeError: window._sharedData.entry_data is undefined
- Reels downloader
- instapy can't install opencv python don't work
- Unable to save account progress, skipping data update b"invalid literal for int() with base 10: '23\\nfollowers'" HOT 6
- Hhvh
- import imp ModuleNotFoundError: No module named 'imp' HOT 2
- Insta.py
- Insta HOT 1
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 instapy.