Created
February 20, 2019 09:12
-
-
Save itst/56a06d918ba0467ca70dd3eff615e680 to your computer and use it in GitHub Desktop.
Using Safari and DEVONagent to download your contacts' vCards off XING. Rewrite it to download with Safari or create a textfile with all the links.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
tell application "Safari" | |
set nextPage to "https://www.xing.com/contacts/contacts" | |
repeat while nextPage is not "-" | |
open location nextPage | |
my waitForPageLoad() | |
delay (random number from 0.2 to 1.0) | |
my getVcardLinks() | |
set nextPage to my gotoNextPage() | |
end repeat | |
end tell | |
on gotoNextPage() | |
try | |
tell application "Safari" to set nextPageCounter to (do JavaScript "document.querySelector('#cl-pagination > nav > ul > li.pagination-single.pagination-next > a').attributes['data-page'].value" in document 1) | |
set nextPageURL to "https://www.xing.com/contacts/contacts?page=" & nextPageCounter & "&initial=&order_by=last_name&cities%5B%5D=&companies%5B%5D=&tags%5B%5D=&no_tags=&query=&view_type=detailed&custom_url=false" | |
on error | |
set nextPageURL to "-" | |
end try | |
return nextPageURL | |
end gotoNextPage | |
on getVcardLinks() | |
tell application "Safari" to set num_links to (do JavaScript "document.links.length" in document 1) | |
set linkCounter to num_links - 1 | |
tell application "DEVONagent" to stop downloads | |
repeat with i from 0 to linkCounter | |
tell application "Safari" to set theLink to do JavaScript "document.links[" & i & "].href" in document 1 | |
if theLink contains "?op=vcard&scr_id=" then | |
tell application "DEVONagent" to add download theLink | |
end if | |
end repeat | |
end getVcardLinks | |
on waitForPageLoad() | |
tell application "Safari" to repeat until (do JavaScript "document.links.length" in document 1) > 200 | |
delay 0.2 | |
end repeat | |
end waitForPageLoad |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment