Jump to content

WinterSummer

New Members
  • Posts

    7
  • Joined

  • Last visited

Posts posted by WinterSummer

  1. Have you tried testing such a theory to see if it works? That's a huge part of being a programmer you know. We don't just know every solution to every problem, and we don't just know if a solution will even work. We get a problem, we think about it for a bit, and we go "Huh, I wonder if this crazy ass idea might work?" And then we try it out.

     

    I'm not very good at programming so my ideas might be very inefficient, that's why I am asking you guys if this is a good way to complete the task or if I'm just inventing the wheel again.

     

    Can't you tell the text file there is a big shoe sale?

     

    There are names that males and females share.

     

    It doesn't have to be 100% accurate, I just want to filter out the obvious ones. Some usernames are impossible to set a gender to since there can be usernames with names such as hippolol, nananabatman, awake24.7 etc.

  2. I have been working on the code and it currently looks like this:

    <?php
    
    		
    function get_data($url) {
    
    	$ch = curl_init();
    	$timeout = 30;
    	curl_setopt($ch, CURLOPT_URL, $url);
    	curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    	curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $timeout);
    	curl_setopt($ch,CURLOPT_USERAGENT,'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.13) Gecko/20080311 Firefox/2.0.0.13');
    	curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
    	curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
    
    	$data = curl_exec($ch);
    
    	if(curl_errno($ch)) {
      		echo 'Curl error: ' . curl_error($ch);
    	}
    		
    	curl_close($ch);
    	return $data;
    }
    
    	$valid_username = array(); 
    
    	$handle = fopen("usernames.txt", "r");
    
    	if ($handle) {
        	while (($username = fgets($handle)) !== false) {
    	       
    	        $url = "facebook.com/" . trim($username);
    	        $source = get_data($url);
    	        echo $url . "<br />";
    	        
    	       	if(preg_match_all('/<div class="coverBorder">/', $source, $matches)) { // If user exists, print its name. <div class="coverBorder"> confirms that the user exists since this class does not exist on Facebook's 404 page
    	        	echo "<font color='green'>" . $username . "</font>";
    	        	array_push($valid_username, $username);
    	        }
    
    
            	else
            		echo "<font color='red'>" . $username . "</font><br />";
    
            	echo "<hr />";
            
        }
    
    
        fclose($handle);
    	
    	} else {
        	echo "Error opening file";
    	} 
    
    
    
    ?>
    

    What I don't understand is that it's reporting false on some of the usernames even if though they do exist:

     

    lisa and johanna should be green, not red!

     

    359fb6a2167526e35dd57bcbda78fbbc.png

  3. 30k usernames in a .txt file mixed with both guys and females, example of a few usernames:

     

    johan92.freak

    amandaCandy

    WinAnna

    .112Johan

     

    I was thinking of downloading a big list of most popular female names in USA (most names are american), then I check if the usernames in the .txt file contains a female name. Is this gonna take a long time to go through a list with 30k usernames?

     

    Can someone help me with understand exactly how this process will look?

     

    >open 30k username list

    >open female name list

    >take first username from list and use regex to see if it contains any name from the female list, if it doesn't, save it to an array and go to next username from the 30k username list and loop

    >save the array to a .txt file with only males as output

     

     

  4. This worked very good, I love you! :D

     

    Now I want to save all usernames that exists in a .txt file that gets downloaded to my computer when I visit the website. How do I achieve that?

    if ($handle) {
        while ($username = fgets($handle) !== false) {
           $url = "https://facebook.com/" . trim($username);
    
    
           $source = get_data($url);
           if (preg_match_all('/<div class="coverBorder">/', $source, $matches))  // If user exists, print its name ($line). <div class="coverBorder"> confirms that the user exists since this class does not exist on Facebook's 404 page
            //Save $username in an array then export it to a .txt file?
           }
    
    
           fclose($handle);
    
    
    } else {
        echo "Error opening file";
    }
    
  5. I have a .txt files that contains a few facebook usernames and I want to check if those usernames exists, i.e if Facebook returns a real profile or if it returns a 404 page. I want to save all usernames that exists in a .txt file.

     

       


    function get_data($url) {
    $ch = curl_init();
    $timeout = 100;


    curl_setopt($ch, CURLOPT_URL, $url);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $timeout);
    curl_setopt($ch,CURLOPT_USERAGENT,'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.13) Gecko/20080311 Firefox/2.0.0.13');
    curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);


    $data = curl_exec($ch);


    if (curl_errno($ch)) {
      echo 'Curl error: ' . curl_error($ch);
    }


    curl_close($ch);


    return $data;
    }


    $handle = fopen("usernames.txt", "r");


    if ($handle) {
        while ($username = fgets($handle) !== false) {
           echo $url = "https://facebook.com/" . $username;


           $source = get_data($url);
          if (preg_match_all('/<div class="coverBorder">/', $source, $matches))  // If user exists, print its name ($line). <div class="coverBorder"> confirms that the user exists since this class does not exist on Facebook's 404 page
            echo $matches;
           }


           fclose($handle);


    } else {
        echo "Error opening file";

     

    I get those errors:

     

        https://facebook.com/sanna Curl error: Illegal characters found in URLhttps://facebook.com/asodkasopdkaopsasf Curl error: Illegal characters found in URLhttps://facebook.com/jana Curl error: Illegal characters found in URLhttps://facebook.com/henrik

      

      

    usernames.txt looks like:  

     

    sanna  

    asodkasopdkaopsasf  

    jana  

    henrik   

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.