So, you have a bloody Xing account and you want to backup your contacts? But you don't want to upgrade to become a premium member (which I would recommend if you're a regular Xing user and want to backup your contacts on a regular basis) because you plan on leaving the platform anyway? If that's the case the following might be of interest to you
.
Yesterday I decided that I want to leave Xing for the better. I just didn't get any use out of the platform. In the 3 years I was a member I didn't participate in any groups, nor did I actively manage my network. I accepted contacts when they approached me, but that's about it. Most of my contacts are either work colleagues or people I know in person and I think I really don't need to be a Xing member to just, well, manage that data. On the other hand I have a linkedin account as well. I might need to put some work into that though. In any case, I consider my linkedin account more valuable in terms of networking than my Xing account and most of my important contacts are on linkedin too anyway.
So I needed a way get all my contacts of the platform, just to be sure my local address book isn't out of sync (I'm not really into contact management so it is probably way out of sync). Xing however, provides a function to export all vCards in one go for premium members only.
Sorry guys, but I don't want to go premium just before leaving Xing.
IMPORTANT: Xing's TOS don't allow to use scripts to interact with the Xing website. I would have used an API, as stated in the TOS, but I couldn't find any references if this API does even exist
. If I'm wrong please point me into the right direction, but, I share tante's opinion on the matter. So, use this script on your own risk! I am not responsible for any implications the usage of this script has regarding your relations with Xing.
Okay, back to the story: I wrote a little bash script which utilises wget and sed to fetch the vCards of my Xing contacts.
To run the script just download it from below, put it in your ~/bin directory and make it executable. The script will download the vCards of your contacts into the current directory when you execute it. It accepts one parameter, namely the number of pages it needs to check to get all your contacts. To find out about that number, just go to your Xing contacts page and switch to vCard view. The last number of the pagination links below the vCards is the number you need. And last not least you also have to set your username and password inside the script to make it work.
The script will sleep 2 seconds after each fetched vCard prevent the script from hammering the Xing servers. If you have lots of contacts you might wanna go and do something else while it's running. The error handling of the script is pretty basic, it won't let you know if a download fails, but you can check if everything worked correctly by just counting the number of vCard files against your number of contacts when the script has finished.
That's it! Have fun leaving Xing!
%> ~/bin/xingscrape.sh 7 Authenticating ... Fetching vcards ... Peter Lustig ... ... ... Done! %> ls -l | wc -l 77
And here's the script:
#!/bin/bash user='XINGUSERNAME' pass='XINGPASSWORD' # script start if [[ $# -lt 1 ]]; then echo "Error: missing offset" echo echo "Usage: $0 [offset]" exit 1 fi count=$1 url='https://www.xing.com/app/contact?notags_filter=0;card_mode=1;search_filter=;tags_filter=;offset=' useragent="Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1) Gecko/20090624 Firefox/3.5" # authenticate and save cookie echo "Authenticating ..." wget --cookies=on \ --keep-session-cookies \ --save-cookies=cookie.txt \ --post-data="login_user_name=${user}&login_password=${pass}&remember-login=1&op=login" \ --user-agent=${useragent} \ --quiet \ -O - \ https://www.xing.com/app/user \ > /dev/null # dumb check if auth worked if [ $(wc -l cookie.txt | cut -c 1) -lt 6 ]; then echo -n "Boo, auth failed :-/!" exit 1 fi # lets do all the work echo "Fetching vcards ..." for i in $(seq 0 $count); do # fetch vcard urls vcards=$(wget --referer="https://www.xing.com/app/user?op=home" \ --cookies=on \ --load-cookies=cookie.txt \ --keep-session-cookies \ --save-cookies=cookie.txt \ --user-agent=${useragent} \ --quiet \ -O - \ "https://www.xing.com/app/contact?notags_filter=0;card_mode=1;search_filter=;tags_filter=;offset=$(($i*12))" \ | sed -n 's/.*href="\([^"]*vcard[^"]*\)".*/\1/p') # fetch each vcard for vcard in $vcards; do fname=$(echo $vcard | cut -d \= -f3) response=$(wget --referer="https://www.xing.com/app/user?op=home" \ --cookies=on \ --load-cookies=cookie.txt \ --keep-session-cookies \ --save-cookies=cookie.txt \ --user-agent=${useragent} \ -O $fname \ https://www.xing.com${vcard} 2>&1) # check HTTP response if we got the vcard echo $response | egrep -i "200 OK" > /dev/null if [ $? == 0 ]; then # give vcard file a proper name contact=$(head -n4 $fname | tail -n1 | cut -d \: -f2 | tr -d [:cntrl:] | iconv -f ISO-8859-1 -t UTF-8) mv $fname $contact echo "$contact ..." else rm $fname fi # don't hammer their servers sleep 2 done done # delete cookie etc rm cookie.txt echo "Done!"
Of course there's room for improvements. If you have an idea how to make this script better just let me know in the comments
.
Suggestion for the help function: the word “offset” is irritating - it is rather the maximum count of profile pages. This means you append the number of contact pages (div 12) you have in xing as parameter.
joooo
Thanks, works fine - expect that the extrcting of filenames resulted in spaces in $contact. Therefore, the move failed. For fixing the move, I just added 'tr -d [” ”] | ' into the line above.
Best regards, joooo