Skip to content

Instantly share code, notes, and snippets.

@liruqi
Last active December 26, 2019 10:04
Show Gist options
  • Select an option

  • Save liruqi/7f425bd570fa8a7c73be to your computer and use it in GitHub Desktop.

Select an option

Save liruqi/7f425bd570fa8a7c73be to your computer and use it in GitHub Desktop.

Revisions

  1. liruqi renamed this gist Jun 17, 2015. 1 changed file with 0 additions and 0 deletions.
    File renamed without changes.
  2. liruqi revised this gist Jun 17, 2015. 1 changed file with 45 additions and 0 deletions.
    45 changes: 45 additions & 0 deletions facebook_fans_by_plugin
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,45 @@
    <?php
    //
    function fetch_fb_fans($fanpage_name, $no_of_retries = 10, $pause = 100000 /* 500ms */){
    $ret = array();
    // get page info from graph
    $fanpage_data = json_decode(file_get_contents('http://graph.facebook.com/' . $fanpage_name), true);
    if(empty($fanpage_data['id'])){
    // invalid fanpage name
    return $ret;
    }
    $matches = array();
    $url = 'http://www.facebook.com/plugins/fan.php?connections=100&id=' . $fanpage_data['id'];
    echo $url . "\n";
    for($a = 0; $a < $no_of_retries; $a++){
    $randIP = "".mt_rand(0,255).".".mt_rand(0,255).".".mt_rand(0,255).".".mt_rand(0,255);
    $context = stream_context_create(array('http' => array('header' => 'User-Agent: Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:22.0) Gecko/20100101 Firefox/22.0\nX-Forwarded-For:' . $randIP)));

    $like_html = file_get_contents($url, false, $context);
    preg_match_all('{href="https?://www\.facebook\.com/([a-zA-Z0-9._-]+)" data-jsid="anchor" target="_blank"}', $like_html, $matches);
    if(empty($matches[1])){
    // failed to fetch any fans - convert returning array, cause it might be not empty
    // return array_keys($ret);
    $pause = $pause * 2;
    echo "# failed: {$pause}";
    }else{
    $all = ($matches[1]);
    foreach ($all as $key => $value) {
    if (isset($ret[$value])) {
    echo ".\n";
    continue;
    } else {
    $ret[$value] = 1;
    echo "{$value}@facebook.com\n";
    }
    }
    // merge profiles as array keys so they will stay unique
    // $ret = array_merge($ret, array_flip($matches[1]));
    }
    // don't get banned as flooder
    usleep($pause);
    }
    return array_keys($ret);
    }

    print_r(fetch_fb_fans('Lamoda.ru', 10000));
  3. liruqi revised this gist Jun 11, 2015. 1 changed file with 7 additions and 5 deletions.
    12 changes: 7 additions & 5 deletions facebook_email.js
    Original file line number Diff line number Diff line change
    @@ -1,6 +1,6 @@
    var run = 0;
    var mails = {}
    total = 30; //滚动次数,可以自己根据情况定义
    total = 3000; //滚动次数,可以自己根据情况定义

    function getEmails (cont) {
    var friendbutton=cont.getElementsByClassName("_ohe");
    @@ -38,21 +38,23 @@ function moreScroll() {
    var cont = document.getElementById(containerID);
    if (cont) {
    run++;
    getEmails(cont);
    var id = run - 2;
    if (id > 0) {
    if (id >= 0) {
    setTimeout(function() {
    containerID = "fbBrowseScrollingPagerContainer" + (id);
    var delcont = document.getElementById(containerID);
    if (delcont) {
    getEmails(delcont);
    delcont.parentNode.removeChild(delcont);
    window.scrollTo(0, document.body.scrollHeight);
    }
    window.scrollTo(0, document.body.scrollHeight - 10);
    }, 1000);
    }
    } else {
    console.log("# " + containerID);
    }
    if (run < total) {
    window.scrollTo(0, document.body.scrollHeight);
    window.scrollTo(0, document.body.scrollHeight + 10);
    }
    setTimeout(moreScroll, 2000);
    }//1000为间隔时间,也可以根据情况定义
  4. liruqi revised this gist Jun 9, 2015. 1 changed file with 6 additions and 4 deletions.
    10 changes: 6 additions & 4 deletions facebook_email.js
    Original file line number Diff line number Diff line change
    @@ -41,11 +41,13 @@ function moreScroll() {
    getEmails(cont);
    var id = run - 2;
    if (id > 0) {
    containerID = "fbBrowseScrollingPagerContainer" + (id);
    var delcont = document.getElementById(containerID);
    delcont.parentNode.removeChild(delcont);
    setTimeout(function() {
    containerID = "fbBrowseScrollingPagerContainer" + (id);
    var delcont = document.getElementById(containerID);
    delcont.parentNode.removeChild(delcont);
    window.scrollTo(0, document.body.scrollHeight);
    }, 1000);
    }

    } else {
    console.log("# " + containerID);
    }
  5. liruqi revised this gist Jun 9, 2015. 1 changed file with 0 additions and 1 deletion.
    1 change: 0 additions & 1 deletion facebook_email.js
    Original file line number Diff line number Diff line change
    @@ -56,4 +56,3 @@ function moreScroll() {
    }//1000为间隔时间,也可以根据情况定义

    moreScroll();

  6. liruqi revised this gist Jun 9, 2015. 1 changed file with 21 additions and 18 deletions.
    39 changes: 21 additions & 18 deletions facebook_email.js
    Original file line number Diff line number Diff line change
    @@ -2,14 +2,7 @@ var run = 0;
    var mails = {}
    total = 30; //滚动次数,可以自己根据情况定义

    function getEmails () {
    var text="";
    containerID = "BrowseResultsContainer"
    if (run > 0) {
    containerID = "fbBrowseScrollingPagerContainer" + (run-1);
    }
    console.log("# " + containerID);
    var cont = document.getElementById(containerID);
    function getEmails (cont) {
    var friendbutton=cont.getElementsByClassName("_ohe");
    for(var i=0; i<friendbutton.length; i++) {
    var link = friendbutton[i].getAttribute("href");
    @@ -22,8 +15,6 @@ function getEmails () {
    if (path == "profile.php") {
    search = parser.search.substr(1);
    var args = search.split('&');
    //console.log(search)
    //console.log(args)
    email = args[0].split('=')[1] + "@facebook.com\n";
    } else {
    email = parser.pathname.substr(1) + "@facebook.com\n";
    @@ -36,21 +27,33 @@ function getEmails () {
    }
    }
    }
    // console.log(text)
    setTimeout(function cmRemoveChild (argument) {
    if (cont) cont.parentNode.removeChild(cont);
    }, 500);
    }

    function moreScroll() {
    getEmails();

    var text="";
    containerID = "BrowseResultsContainer"
    if (run > 0) {
    containerID = "fbBrowseScrollingPagerContainer" + (run-1);
    }
    var cont = document.getElementById(containerID);
    if (cont) {
    run++;
    getEmails(cont);
    var id = run - 2;
    if (id > 0) {
    containerID = "fbBrowseScrollingPagerContainer" + (id);
    var delcont = document.getElementById(containerID);
    delcont.parentNode.removeChild(delcont);
    }

    } else {
    console.log("# " + containerID);
    }
    if (run < total) {
    window.scrollTo(0, document.body.scrollHeight);
    run++;
    }

    setTimeout(moreScroll, 2000);
    }//1000为间隔时间,也可以根据情况定义

    moreScroll();

  7. liruqi revised this gist Jun 9, 2015. 1 changed file with 20 additions and 15 deletions.
    35 changes: 20 additions & 15 deletions facebook_email.js
    Original file line number Diff line number Diff line change
    @@ -1,10 +1,14 @@
    var run = 0;
    total = 3000; //滚动次数,可以自己根据情况定义
    var mails = {}
    total = 30; //滚动次数,可以自己根据情况定义

    function getEmails () {
    var text="";
    containerID = "fbBrowseScrollingPagerContainer" + nodeID;
    // console.log(containerID);
    containerID = "BrowseResultsContainer"
    if (run > 0) {
    containerID = "fbBrowseScrollingPagerContainer" + (run-1);
    }
    console.log("# " + containerID);
    var cont = document.getElementById(containerID);
    var friendbutton=cont.getElementsByClassName("_ohe");
    for(var i=0; i<friendbutton.length; i++) {
    @@ -20,14 +24,22 @@ function getEmails () {
    var args = search.split('&');
    //console.log(search)
    //console.log(args)
    text+=args[0].split('=')[1] + "@facebook.com\n";
    email = args[0].split('=')[1] + "@facebook.com\n";
    } else {
    text+=parser.pathname.substr(1) + "@facebook.com\n";
    email = parser.pathname.substr(1) + "@facebook.com\n";
    }
    if (mails[email] > 0) {
    continue;
    }
    mails[email] = 1;
    console.log(email);
    }
    }
    }
    console.log(text)
    // console.log(text)
    setTimeout(function cmRemoveChild (argument) {
    if (cont) cont.parentNode.removeChild(cont);
    }, 500);
    }

    function moreScroll() {
    @@ -37,15 +49,8 @@ function moreScroll() {
    window.scrollTo(0, document.body.scrollHeight);
    run++;
    }
    setTimeout(function cmRemoveChild (argument) {
    for(var nodeID = 0; nodeID<run - 1; nodeID++) {
    containerID = "fbBrowseScrollingPagerContainer" + nodeID;
    // console.log(containerID);
    var cont = document.getElementById(containerID);
    if (cont) cont.parentNode.removeChild(cont);
    }
    }, 500);

    setTimeout(moreScroll, 2000);
    }//1000为间隔时间,也可以根据情况定义

    moreScroll();
    moreScroll();
  8. liruqi created this gist Jun 9, 2015.
    51 changes: 51 additions & 0 deletions facebook_email.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,51 @@
    var run = 0;
    total = 3000; //滚动次数,可以自己根据情况定义

    function getEmails () {
    var text="";
    containerID = "fbBrowseScrollingPagerContainer" + nodeID;
    // console.log(containerID);
    var cont = document.getElementById(containerID);
    var friendbutton=cont.getElementsByClassName("_ohe");
    for(var i=0; i<friendbutton.length; i++) {
    var link = friendbutton[i].getAttribute("href");

    if(link && link.substr(0,25)=="https://www.facebook.com/") {
    var parser = document.createElement('a');
    parser.href = link;
    if (parser.pathname) {
    path = parser.pathname.substr(1);
    if (path == "profile.php") {
    search = parser.search.substr(1);
    var args = search.split('&');
    //console.log(search)
    //console.log(args)
    text+=args[0].split('=')[1] + "@facebook.com\n";
    } else {
    text+=parser.pathname.substr(1) + "@facebook.com\n";
    }
    }
    }
    }
    console.log(text)
    }

    function moreScroll() {
    getEmails();

    if (run < total) {
    window.scrollTo(0, document.body.scrollHeight);
    run++;
    }
    setTimeout(function cmRemoveChild (argument) {
    for(var nodeID = 0; nodeID<run - 1; nodeID++) {
    containerID = "fbBrowseScrollingPagerContainer" + nodeID;
    // console.log(containerID);
    var cont = document.getElementById(containerID);
    if (cont) cont.parentNode.removeChild(cont);
    }
    }, 500);
    setTimeout(moreScroll, 2000);
    }//1000为间隔时间,也可以根据情况定义

    moreScroll();