Navigate to tweet and replies instead of only the profile
This commit is contained in:
parent
408a2b0845
commit
d0b739acf8
2 changed files with 20 additions and 2 deletions
|
@ -95,6 +95,11 @@ let go_to_profile ctx =
|
|||
then raise (Any "Too many profile button found")
|
||||
else List.nth l 0
|
||||
in
|
||||
click ctx.session_id profile_button;
|
||||
Unix.sleep 4
|
||||
ignore
|
||||
(navigate
|
||||
ctx.session_id
|
||||
(fmt "https://twitter.com%s/with_replies" (get_url ctx.session_id profile_button)));
|
||||
Unix.sleep 2
|
||||
;;
|
||||
|
||||
let find_latest_tweet = ()
|
||||
|
|
13
lib/net.ml
13
lib/net.ml
|
@ -128,3 +128,16 @@ let click session_id element_id =
|
|||
(fmt "%s/element/%s/click" (driver session_id) element_id)
|
||||
Json.empty)
|
||||
;;
|
||||
|
||||
let get_url session_id button_id =
|
||||
let response =
|
||||
execute_get_request (fmt "%s/element/%s/attribute/href" (driver session_id) button_id)
|
||||
in
|
||||
match Yojson.Safe.from_string response with
|
||||
| `Assoc fields ->
|
||||
(match List.assoc "value" fields with
|
||||
| `String href -> href
|
||||
| _ as e ->
|
||||
raise (Any (fmt "Unexpected response from driver: %s" (Yojson.Safe.to_string e))))
|
||||
| _ -> raise (Any "get_url | Invalid JSON")
|
||||
;;
|
||||
|
|
Loading…
Reference in a new issue