How can I monitor memory consumption during webserver stress test? - php

I want to do a stress test on an Apache webserver that I have running on localhost. The test will request the webserver to execute a PHP application that I wrote. I want to see how much memory (RAM) the webserver (and/or the associated PHP process) consumes during the test. Or to see how much it consumed after the test is done.
My OS is Ubuntu 13.10.
I looked at Apache Bench, Apache JMeter, Siege and httperf. None of them seem to provide such information. At most, I can see some CPU load in httperf (which in most cases is 100 %, so not too relevant).
Is there some tool that can provide me with memory consumption information ? It doesn't have to be a webserver benchmarking tool, could also be another Linux software that runs in parallel with the benchmarking tool. I just think that manually monitoring the test via the top command is kind of innacurate/ammateurish. Thank you in advance.

htop may be exactly what you're looking for.
Personally, I recently discovered something called byobu - which gives you a handy readout on the bottom (which you can configure by pressing F9) --
And that has become my personal favorite for exactly what you're describing.
Although, you could also look into xdebug -- and use something like xdebug_memory_usage() -- in the php script you're testing to dump info into a log file at key points in your script

I've put up a few PHP cronjobs, too, when I manually start the script through console I want to see debug and stuff, too.
I put in a method like this:
protected $consoleUpdate;
protected function printMemoryUsage() {
if ((time() - $this->consoleUpdate) >= 3) {
$this->consoleUpdate = time();
echo "Memory: ",
round(memory_get_usage(true) / (1024 * 1024)),
" MB",
"\r";
}
}
Call this method as often as you like to print the scripts memory usage.
Notice the final \r in the console, which returns the cursor to the line beginning and overwrites the line. If you don't have any other output, this has the effect of your screen not moving, instead, it gets updated.

Things like top, htop, memstat, iotop, mysqltop. All these tools are excellent to see what is thoroughly cooking your server while you throw siege (and its friend apachebench) at it.

I use vmstat for memory, disk and CPU monitoring. Below are some measurements whilst copying files on a bottom of the heap Linux based Raspberry Pi. I first used vmstat in the 1980’s, monitoring DB activity on early Unix systems. More details in:
http://www.roylongbottom.org.uk/Raspberry%20Pi%20Stress%20Tests.htm
vmstat was either run from a separate terminal or in a combined script file.
pi#raspberrypi /mnt $ time sudo sh -c "cp -r 256k /mnt/new2 && sync"
40 samles at 1 second intervals
vmstat 1 40 > vmstatRes.txt
real 0m38.781s
user 0m0.400s
sys 0m8.400s
procs -----------memory---------- ---swap-- -----io---- -system-- ----cpu----
r b swpd free buff cache si so bi bo in cs us sy id wa
0 0 0 304684 15208 65952 0 0 0 0 1109 319 39 2 59 0
1 0 0 282788 15208 87308 0 0 10292 0 4018 2994 5 57 9 29
1 1 0 256996 15208 112768 0 0 12380 0 4687 3863 3 53 0 44
2 2 0 231452 15212 138028 0 0 12288 40 4781 4024 5 55 0 40
0 1 0 216576 15216 152476 0 0 7004 10512 5649 3580 5 50 0 46
2 2 0 201688 15216 167288 0 0 7144 17488 5341 3527 2 52 0 46
1 0 0 195064 15216 173808 0 0 3192 9016 5909 3214 2 34 0 64
3 0 0 169520 15216 199152 0 0 12304 0 4704 3914 2 60 0 38
2 3 0 149988 15220 218288 0 0 9252 9892 5003 3614 2 52 0 45
0 2 0 131008 15224 237072 0 0 9112 10324 5086 3568 2 54 0 44
1 0 0 120160 15224 247784 0 0 5232 0 4976 2935 0 34 0 66
0 1 0 110424 15224 257404 0 0 4628 12864 5097 3034 4 36 0 60
1 0 0 86556 15224 281120 0 0 11536 0 4965 3874 3 54 0 43
1 1 0 73784 15224 293816 0 0 6188 11592 5545 3514 2 46 0 52
1 1 0 63252 15232 304132 0 0 4968 10320 4617 2748 2 34 0 64
0 1 0 43148 15232 323960 0 0 9652 7184 5126 3749 2 54 0 43
0 1 0 29336 15232 337560 0 0 6596 10036 4311 2796 2 38 0 59
1 1 0 23944 11696 346276 0 0 7480 0 5465 3455 2 46 0 52
2 1 0 23076 9580 349184 0 0 2860 10524 4521 2323 1 35 0 64
2 1 0 24440 5300 351508 0 0 8864 5188 4586 3215 1 66 0 33
0 1 0 24500 3900 352704 0 0 4896 11448 5974 3308 2 49 0 49
1 1 0 24432 3772 352700 0 0 10424 6208 4851 3682 2 60 0 38
1 1 0 23764 3772 353736 0 0 6568 5184 5970 3526 1 45 0 53
1 1 0 24068 3776 353500 0 0 4900 11388 5449 3142 0 40 0 60
0 1 0 24400 3780 352552 0 0 10068 8848 4821 3531 2 57 0 40
1 1 0 24152 3772 352588 0 0 8292 2784 5207 3588 2 50 0 48
1 1 0 23516 3772 353620 0 0 6800 7816 5475 3475 1 49 0 49
0 1 0 24260 3772 352940 0 0 7004 7424 5042 3284 4 43 0 52
2 1 0 24068 3776 353060 0 0 4624 10292 4798 2801 0 39 0 61
2 0 0 23820 3780 353340 0 0 8844 5508 5251 3609 0 56 0 44
2 1 0 24252 3772 352528 0 0 4552 12000 5053 2841 2 44 0 54
1 1 0 23696 3772 353120 0 0 10880 2176 4908 3694 2 58 0 40
1 0 0 24260 3772 352212 0 0 3748 11104 5208 2904 2 34 0 63
3 2 0 24136 3780 352084 0 0 10148 1628 4637 3568 1 55 0 44
0 1 0 24192 3780 352120 0 0 4016 10260 4719 2613 1 31 0 68
1 1 0 24392 3772 352076 0 0 6804 10972 5386 3473 1 52 0 47
1 1 0 24392 3772 351704 0 0 8568 8788 5101 3502 2 61 0 36
0 1 0 24376 3780 351764 0 0 0 30036 6711 1888 0 36 0 64
0 1 0 24252 3780 351928 0 0 28 2072 5629 1354 0 10 0 90
0 0 0 24768 3780 351968 0 0 40 20 1351 579 9 6 13 72
1 0 0 24768 3780 351968 0 0 0 0 1073 55 1 1 98 0

Related

Find and Replace a Column in CSV1 based on CSV2 in PHP

I am trying replace the values of column "Close" in the first CSV with the values of column "LTP" in the second CSV where the following columns should be same in CSV2 and CSV1:
"Symbol=SYMBOL", "Date=TIMESTAMP", "Expiry=EXPIRY_DT", "Option Type=OPTION_TYP", "Strike Price=STRIKE_PR"
Here is the current structure of CSV1:
INSTRUMENT SYMBOL EXPIRY_DT STRIKE_PR OPTION_TYP OPEN HIGH LOW CLOSE SETTLE_PR CONTRACTS VAL_INLAKH OPEN_INT CHG_IN_OI TIMESTAMP
OPTSTK INFY 26-Apr-18 780 CE 0 0 0 408.6 361.05 0 0 0 0 2-Apr-18
OPTSTK INFY 26-Apr-18 800 CE 0 0 0 388.95 341.15 0 0 0 0 2-Apr-18
OPTSTK INFY 26-Apr-18 820 CE 0 0 0 369.35 321.25 0 0 0 0 2-Apr-18
OPTSTK INFY 26-Apr-18 840 CE 0 0 0 349.75 301.35 0 0 0 0 2-Apr-18
OPTSTK INFY 26-Apr-18 860 CE 0 0 0 330.2 281.45 0 0 0 0 2-Apr-18
OPTSTK INFY 26-Apr-18 880 CE 0 0 0 310.75 261.55 0 0 0 0 2-Apr-18
OPTSTK INFY 26-Apr-18 900 CE 0 0 0 291.35 241.65 0 0 0 0 2-Apr-18
OPTSTK INFY 26-Apr-18 920 CE 0 0 0 272.15 221.75 0 0 0 0 2-Apr-18
OPTSTK INFY 26-Apr-18 940 CE 0 0 0 216 201.85 0 0 5400 0 2-Apr-18
OPTSTK INFY 26-Apr-18 960 CE 0 0 0 234.45 181.95 0 0 0 0 2-Apr-18
OPTSTK INFY 26-Apr-18 980 CE 0 0 0 216.1 162.1 0 0 0 0 2-Apr-18
OPTSTK INFY 26-Apr-18 1000 CE 0 0 0 136 142.3 0 0 24600 0 2-Apr-18
And the structure of CSV2 is:
Symbol Date Expiry Option Type Strike Price Open High Low Close LTP Settle Price No. of contracts Turnover in Lacs Premium Turnover in Lacs Open Int Change in OI Underlying Value
INFY 2-Apr-18 26-Apr-18 CE 780 0 0 0 408.6 0 361.05 0 0 0 0 0 1137.15
INFY 2-Apr-18 26-Apr-18 CE 1380 1 1 1 1 1 1 1 8.29 0.01 600 600 1137.15
INFY 2-Apr-18 26-Apr-18 CE 820 0 0 0 369.35 0 321.25 0 0 0 0 0 1137.15
INFY 2-Apr-18 26-Apr-18 CE 840 0 0 0 349.75 0 301.35 0 0 0 0 0 1137.15
INFY 2-Apr-18 26-Apr-18 CE 860 0 0 0 330.2 0 281.45 0 0 0 0 0 1137.15
INFY 2-Apr-18 26-Apr-18 CE 880 0 0 0 310.75 0 261.55 0 0 0 0 0 1137.15
INFY 2-Apr-18 26-Apr-18 CE 900 0 0 0 291.35 0 241.65 0 0 0 0 0 1137.15
INFY 2-Apr-18 26-Apr-18 CE 920 0 0 0 272.15 0 221.75 0 0 0 0 0 1137.15
INFY 2-Apr-18 26-Apr-18 CE 940 0 0 0 216 216 201.85 0 0 0 5400 0 1137.15
INFY 2-Apr-18 26-Apr-18 CE 960 0 0 0 234.45 0 181.95 0 0 0 0 0 1137.15
INFY 2-Apr-18 26-Apr-18 CE 980 0 0 0 216.1 0 162.1 0 0 0 0 0 1137.15
INFY 2-Apr-18 26-Apr-18 CE 1000 0 0 0 136 134 142.3 0 0 0 24600 0 1137.15
INFY 2-Apr-18 26-Apr-18 CE 1020 0 0 0 126 126 122.65 0 0 0 1200 0 1137.15
A few things about CSV and in general any file
I am trying replace the values of column "Close" in the first CSV with the values of column "LTP" in the second CSV where the following columns.
You cannot "replace" anything in the file. You can however pull the data from a file using fgetcsv then change it and write a new file with the changed data using fputcsv.
As you have shown "no code", I won't bother writing much. But I will just go over the process.
read in the file (completely) with the new values in it, creating an array from it
read in the file you wish to change row by row
for each row of the second file, find the correct row in the first one (array) and update the data for that line in file #2 (your file #1)
write a new file that contains the updated data.
you have to read the file you want to change the data in last, because you want to preserve the order of the rows in that file, and well it's just easier that way.
A tip for matching the data. When you read in file #1 take the fields you need to match and hash them using md5. Md5 is really fast on the order of something like 5 million hashes a second (yes I timed it)
$time = microtime(true);
for($i=0; $i <= 5000000; ++$i){
md5("hello world");
}
echo "Complete :".number_format((microtime(true) - $time), 4);
Try it yourself
Output
Complete :1.3057
Now this has nothing to do with security or anything else, I will explain in a second.
When you build you array (Step 1) take the fields you want to match and hash them and use that for the key in your array.
$hash = md5(
$row['Symbol'] .
strtotime($row['Date']) . //convert to timestamp
$row['Expiry'] .
$row['Option Typ'] .
$row['Strike Price']
);
$data[$hash] = $row;
Then do the same when you read in the second file (the file you want to modify)
$newHash = md5(
$row['SYMBOL'] .
TIMESTAMP . //convert to timestamp
$row['EXPIRY_DT'] .
$row['OPTION_TYP'] .
$row['STRIKE_PR'] .
);
Then simply look up the hash in the $data array isset($data[$newHash]) as yo go through the file you are modifying. Once you find the row with that data you need the rest is pretty trivial.
Now the basic way to read a file is
$h = fopen('filename.csv', 'r');
$data = [];
$headers = false;
while(!feof($h)){
$row = fgetcsv($h);
if(!$headers) $headers = $row;
$row = array_combine($headers, $row);
//do the hash "and other stuff"
$data[$hash] = $row;
}
Then read the other file after that one is done, with the same kind of loop, do the hash , match the data you want, update the old data, write the row in a new (3rd) file etc...
For the hashing to work, the data must match from one CSV to the other (obviously), there cannot be duplicate "hashed" rows. Rows who's data hashes the same but which has values in the other fields. Like if you had 2 rows in the same file that hash the same and then the Close value is different. This would cause you trouble no matter what.
Good luck, look up some tutorials on how to process CSV files, there are plenty of them out there.

To Convert an unstructured string to 2d array om PHP

I have parsed some data from a file into a string variable,
CPU NFS CIFS HTTP Total Net kB/s HDD kB/s SSD kB/s Tape kB/s Cache Cache CP CP HDD SSD OTHER FCP iSCSI FCP kB/s iSCSI kB/s
in out read write read write read write age hit time ty util util in out in out
65% 0 0 0 11357 97020 2846 0 156160 0 0 0 0 >60 100% 100% :f 45% 0% 3 0 11354 0 0 92987 0
67% 0 0 0 11761 100535 2943 511 161119 0 0 0 0 >60 100% 100% :f 43% 0% 0 0 11761 0 0 96397 0
66% 0 0 0 11911 101736 2984 276 151088 0 0 0 0 >60 100% 100% :v 48% 0% 0 0 11911 0 0 97534 0
56% 0 0 0 12026 102664 3094 36 24 0 0 0 0 >60 100% 1% : 2% 0% 11 0 12015 0 0 98419 0
81% 0 0 0 10023 85660 2317 1964 198416 0 0 0 0 >60 100% 83% Ff 60% 0% 0 0 10023 0 0 82117 0
67% 0 0 0 11914 101825 2993 336 152883 0 0 0 0 >60 100% 100% :f 55% 0% 0 0 11914 0 0 97625 0
67% 0 0 0 11526 98491 2869 256 151040 0 0 0 0 >60 100% 100% :f 51% 0% 0 0 11526 0 0 94388 0
66% 0 0 0 11589 99011 2931 0 143225 0 0 0 0 >60 100% 100% :f 51% 0% 0 0 11589 0 0 94949 0
57% 0 0 0 11869 101355 3032 56 20544 0 0 0 0 >60 100% 26% : 10% 0% 7 0 11862 0 0 97182 0
76% 0 0 0 9408 79189 2212 2022 122504 0 0 0 0 >60 100% 48% Fn 38% 0% 223 0 9185 0 0 75939 0
74% 0 0 0 10978 92981 2651 572 147078 0 0 0 0 >60 100% 100% :f 53% 0% 19 0 10959 0 0 89095 0
67% 0 0 0 11839 101109 2946 8 148332 0 0 0 0 >60 100% 100% :f 56% 0% 0 0 11839 0 0 96954 0
64% 0 0 0 11517 98413 2899 256 138248 0 0 0 0 >60 100% 100% :f 51% 0% 0 0 11517 0 0 94355 0
62% 0 0 0 11653 99151 2920 559 106198 0 0 0 0 >60 100% 81% : 40% 0% 52 0 11601 0 0 95030 0
56% 0 0 0 11765 99752 2973 577 3009 0 0 0 0 >60 100% 3% Fn 2% 0% 100 0 11665 0 0 95652 0
82% 0 0 0 9987 85219 2327 1570 207259 0 0 0 0 >60 100% 100% :f 60% 0% 5 0 9982 0 0 81692 0
67% 0 0 0 11859 101347 2970 0 158696 0 0 0 0 >60 100% 100% :f 57% 0% 0 0 11859
Into a 2D Array, so that I can take average of one of the column ,
Can someone let me know how it is done ?
My code:
preg_match('/'.preg_quote($word1).'(.*?)'.preg_quote($word2).'/is', $akshay_file, $match);
$text2 = nl2br($match[1]);
echo "$text2";
Can someone let me know how it is done, am I doing it the wrong way?
Thanks.
Guess you are reading this from a file. As an option, read the file line by line and consider the following code
<?php
$n = "65% 0 0 0 11357 97020 2846 0 156160 0 0 0 0 >60 100% 100% :f 45% 0% 3 0 11354 0 0 92987 0";
$n = preg_replace('!\s+!', ' ', $n);
$parts = explode(' ', $n);
echo '<pre>'.print_r($parts, true).'</pre>';
?>
At first you should split the code in lines and then split each line by whitespaces.
$lines = preg_split('/$\R?^/m', $data);
foreach ($lines as $line) {
$cols = preg_split('/\s\s+/', $data);
// do sth..
}

number of records between two dates phpmysql

I have this code to get records between two dates $date1 and $date2
for ($i=$date1;$i<$date2;$i++){//BETWEEN THE TWO DATES
$count_rcvd=mysql_num_rows(mysql_query("select * from cards where Date_Rcvd='$i'"));
$count_collect=mysql_num_rows(mysql_query("select * from cards where Date_Collected='$i'"));
if($i==$date1){FOR THE FIRST DATE IN THE RANGE
$uncollected=mysql_num_rows(mysql_query("select * from cards where Status='AVAILABLE' and Date_Rcvd<='$i'"));
$balance=$uncollected;
}
else{//FOR CONSECUTIVE DATES AFTER DATE1
$uncollected=mysql_num_rows(mysql_query("select * from cards where Status='AVAILABLE' and Date_Rcvd<'$i'"));//previous days balance
$balance=$uncollected+$count_rcvd-$count_collect;
When i echo for $i
echo "";
echo $i;
echo "";
echo $count_rcvd;
echo "";
echo $count_collect;
echo "";
echo $balance;
echo "";
I get out below with the date going well beyond the calender dates
014-03-15 0 7 103
2014-03-16 0 3 100
2014-03-17 0 7 96
2014-03-18 0 9 94
2014-03-19 0 5 98
2014-03-20 15 6 112
2014-03-21 0 6 103
2014-03-22 0 1 108
2014-03-23 0 0 109
2014-03-24 0 8 101
2014-03-25 0 3 106
2014-03-26 0 0 109
2014-03-27 1 2 108
2014-03-28 0 0 110
2014-03-29 6 1 115
2014-03-30 0 0 116
2014-03-31 0 0 116
2014-03-32 0 0 116
2014-03-33 0 0 116
2014-03-34 0 0
the problem is the output dates go beyond 31st for example....HELP!!!
To iterate on dates, i recommand you to use DateTime and DateTimeInterval classes (Be careful ! PHP 5.3 minimum) : http://www.php.net/manual/fr/class.datetime.php
You can add days/months following the real calendar : http://www.php.net/manual/fr/datetime.add.php

Twitter api 1.1 is not loading all followers

I have a program to get followers details of a person. the code is working fine upto the follower count 3000. i tried with another person which have 200000 Followers. Unfortunately it is showing only 300 followers why this happen? is there any way to fix this?
Here is my code
<?php
ini_set('max_execution_time', '50000000');
ini_set('post_max_size', '100M');
require_once('TwitterAPIExchange.php');
$consumerKey = 'xxxxxxxxxxxxxxxxxx';
$consumerKeySecret = 'xxxxxxxxxxxxxxxxxxxxxxxxxxxx';
$accessToken = 'xxxxxxxxxxxxxxxxxxxxxxxxx';
$accessTokenSecret = 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx';
$settings = array(
'oauth_access_token' => $accessToken,
'oauth_access_token_secret' => $accessTokenSecret,
'consumer_key' => $consumerKey,
'consumer_secret' => $consumerKeySecret
);
$i = 0;
$cursor = -1;
do {
$url = 'https://api.twitter.com/1.1/followers/list.json';
$getfield = '?cursor='.$cursor.'&screen_name=BeingSalmanKhan&skip_status=true&include_user_entities=false';
$requestMethod = 'GET';
$twitter = new TwitterAPIExchange($settings);
$response = $twitter->setGetfield($getfield)
->buildOauth($url, $requestMethod)
->performRequest();
$response = json_decode($response, true);
$errors = $response["errors"];
if (!empty($errors)) {
foreach($errors as $error){
$code = $error['code'];
$msg = $error['message'];
echo "<br><br>Error " . $code . ": " . $msg;
}
$cursor = 0;
}
else {
$users = $response['users'];
print_r($users);
echo'<table>';
echo '<tr>';
echo '<td>No:</td>';
echo '<td>Name</td>';
echo '<td>Profile Description</td>';
echo '<td>Location</td>';
echo '<td>Followers Count</td>';
echo '<td>Website Url</td>';
echo '<td>Screen Name</td>';
echo '<td>Favourited Tweets</td>';
echo '<td>Language</td>';
echo '<td>Friends Count</td>';
echo '<td>Status</td>';
echo '<td>Image</td>';
echo '</tr>';
foreach($users as $user){
$thumb = $user['profile_image_url'];
$url = $user['screen_name'];
$name = $user['name'];
$description = $user['description'];
$location = $user['location'];
$followers_count = $user['followers_count'];
$url = $user['url'];
$screen_name = $user['screen_name'];
$favourites_count = $user['favourites_count'];
$language = $user['lang'];
$listed_count = $user['listed_count'];
$friends_count = $user['friends_count'];
$status = $user['status'];
echo '<tr>';
echo '<td>'.$i.'</td>';
echo '<td>'.$name.'</td>';
echo '<td>'.$description.'</td>';
echo '<td>'.$location.'</td>';
echo '<td>'.$followers_count.'</td>';
echo '<td>'.$url.'</td>';
echo '<td>'.$screen_name.'</td>';
echo '<td>'.$favourites_count.'</td>';
echo '<td>'.$language.'</td>';
echo '<td>'.$friends_count.'</td>';
echo '<td>'.$status.'</td>';
echo '<td><img src="'.$thumb.'"></td>';
echo '</tr>';
$i++;
}
$cursor = $response["next_cursor"];
}
}
while ( $cursor != 0 );
if (!empty($users)) {
echo '<br><br>Total: ' . $i;
}
?>
Here is the output what i get
0 Rao.navneet101#gmail 0
1 shivangi darshan dos 0
2 Renuka.R.K 0
3 md samiullah khan bokaro steel city 0
4 monusahu 0
5 Vivek mishra 0
6 Mezba Alam Dhaka, Bangladesh. 20
7 shiva krishnam raju 0
8 shankar rupani 0
9 Vasu patil 0
10 keerthi 0
11 love_guru 1
12 abhishek tiwari 0
13 Future Care 0
14 harikumar sreekumar 3
15 Shahnawaz Khan 0
16 prakhar bhushan 0
17 Binita Chhaparia 0
18 venkatesan 1
19 Rahul RJ 0
20 emty Abuja Nigeria 12
21 Nil-Akash Chy smart 0
22 ashok kumar 1
23 azhar 0
24 Prarthana 0
25 Anu bibu 0
26 SAMIR SINGH 0
27 Deemag ki Maa Behen. Saket, New Delhi 35
28 abel leo 0
29 Dhananjay Pawar 0
30 Anuradha Choudhary 1
31 maiome.maiome 0
32 rahul hussey 1
33 vishnupriya 3
34 anggi12345 5
35 farheen naaz haora 0
36 aman 4
37 Shubham Verma Varanasi(UP) 0
38 satish kumar jaiswar 0
39 sheikhwasi 0
40 MUHAMMADUMAR 0
41 Gaurav tiwari India 0
42 arjun malviy 0
43 prashanth 0
44 saloni 0
45 Tanvir,Hridoy 0
46 Mahesh Sharma 0
47 Deepak Aswathnarayan 2
48 devender kumar 0
49 Awal 0
50 Sanketa Kamble 0
51 faraz azhar 1
52 Avinash singh 0
53 KUMAR SUMIT 0
54 Mahuya sultana 0
55 hemant chawla 0
56 Hanii andiraa 0
57 mahendra shah AHMEDABAD 5
58 Angel Preet 0
59 kumar gaurav 0
60 atul kumar bangalore 1
61 saurabh singh 0
62 ajaygadhavi 0
63 Prajkta Waditwar Mumbai 21
64 Shruti 1
65 Prabhakar Gupta 1
66 waseem abbas 0
67 Malik Zulqarnain 0
68 Sk Azharuddin 0
69 MOHIT VIJAY 0
70 RadhaKrishnan chennai 22
71 Ruchita Chaudhari 0
72 MANISH RAWAT 0
73 vyasronit vansba 0
74 SURAJ YADAV 1
75 Akanksha Pratik 0
76 Sandeep goswami 0
77 Rupinder kaur 0
78 abhishek pandey 3
79 imad 2
80 Sandeep rao 0
81 sahil khan 0
82 abdulbari 95
83 Binal Chitroda. 0
84 Sexy boy 0
85 Akash chauhan 1
86 qawserftgyhujik 8
87 dhruvil patel 0
88 Barada sahoo 0
89 Banu 2
90 Uddipta kashyap 0
91 Mitul sharma Jammu 0
92 pankaj singh faridabad, haryana 0
93 Sanjeev krishnan 0
94 adnan ahmed 0
95 Ahad sheikh 0
96 manish shah Rajkot 5
97 VISHAL SINGH 1
98 aksahy 1
99 satya prasanna kkd 23
100 rajesh rana 0
101 Jatt Boys 1
102 Zeel Doshi 22
103 nabin regmi 1
104 aneeta awasthi 0
105 navjit k chopra 1
106 Ashim Mallick 0
107 Rajesh Kumar Mishra 3
108 Rahul pagare 0
109 Lingam k 0
110 Abishek bagmar chennai 32
111 Trang Weinman 0
112 muktadesai 0
113 mansur.ali2009#gmail 0
114 Angel Urvashi amritsar 1
115 rangga nurmansyah 2
116 Rajesh Shetty 1
117 Muhammad Sohail Akba 1
118 waroeng sehat HI 0
119 Montibohra 0
120 siddarth 1
121 SHRAVANI KURRA 0
122 suven sarkar 0
123 ajit suryawanshi 0
124 pappu rakade patil Babra Aurangabad Maharastra 0
125 shiyad shereef 8
126 Sachin Ingale Pune 0
127 archana mishra 0
128 vijayjaware 1
129 Alive Soul 0
130 aakash malhotra 0
131 sheikh mohsin 0
132 Sheryll Franca 0
133 Manjeet Mundhe 6
134 khan sania hong kong 0
135 vishaldev 0
136 grewal laddi 1
137 Sanjay kumar 0
138 j aishwarya rao 2
139 didar khan oman.sadah 0
140 SONI SINGH 0
141 mohit khandelwal 2
142 sunny verma 1
143 Mohinurgazi 0
144 Jitender Kumar 1
145 Vinay jayakumar 0
146 solomonrajesh chennai 2
147 k.nagalakshmi 1
148 jeevankiran 9
149 Raghu 0
150 Alive Chatulistiwa 10
151 ses dubey 0
152 Sumit Zadafiya 1
153 majid abass hassanabad rainawari srinagar 3
154 shubh jain 0
155 M Fuad 0
156 poojashadhijha 0
157 manu garg 0
158 Imran Hussain 0
159 Zain jutt 0
160 k.seven new delhi 0
161 Lakhan Wanole 1
162 Olympia Verrell 0
163 majuanwar 0
164 Page 29 Kolkata, India 0
165 aayushmaan 19
166 prashant gupta 3
167 jose santha seelan 19
168 Mahar Ejaz 1
169 kabeer magsi 0
170 PriNcE SaMeeR 0
171 prashant shrivastava 0
172 Vinod Ghorpade 0
173 eno apriliani 1
174 Pratik Wadkar 0
175 FiRu Kuwait 3
176 Jagtap 0
177 Ravi kumar Giridih 0
178 Ajay Khandelwal 1
179 poojamaurya 0
180 Rajat Chouhan 0
181 Ayanna Nelms 0
182 shrimanth kumar 2
183 SATYANARAYNANDWANA 0
184 AJEESH Ayoor,kollam 10
185 Shah Alam 1
186 Flywell2India ON L5A 1W7, Canada 3
187 banti kashyap jaipur 1
188 ayesha pathan India 10
189 Ranjan SP 44
190 AmarDeep 0
191 Manish Chamling Rai 0
192 Arun kumar 0
193 Mitesh Baranwal Varanasi 11
194 AKHTAR ABBAS 1
195 Toufiq Alahi 0
196 Rajbir Singh 2
197 Syed Irfan Hussain A 1
198 Syed Anwaar Ali indore, India 0
199 MD.SOWKAT Bangladesh 1
200 srinivasan 1
201 Pradeep Sheler 1
202 sagar shergill 0
203 mohanvamsi 0
204 Keshav Singh 0
205 Ankit Verma 0
206 vinod kachare 5
207 Faraz Imam 3
208 Prateek Pathak 16
209 Kumar Abhishek 1
210 rishita gupta 8
211 Krishna Kumar Tiwari 1
212 KALIM KHAN 4
213 VIPIN 0
214 mukund vishwakarma 0
215 jitendra mishra 1
216 Amit kumar 0
217 Tariq 1
218 Sonu Jani 0
219 Naveen Malethiya Sri Ganganagar 0
220 shyam rajput 0
221 Progressive Dental 0
222 Aryan sid 0
223 simran galhotra 6
224 jot singh 0
225 vishnukumar.merugu 1
226 sujal khandelwal 1
227 shashank patel 0
228 suhail khan 3
229 Vedant Jogdand Pune 8
230 Irfanvali 0
231 sakshi vinayak 2
232 Amrapali R. Sarodey 0
233 ????? 1
234 Purnendu Sharma delhi 1
235 lhomingdolma lama Kathmandu, Nepal 0
236 humaira khanam 1
237 mohammadjawed akhter 1
238 Himanshu Rao 0
239 sandeep nargunde 1
240 yuvarajc 3
241 rajesh 0
242 Vithika Sheru 0
243 himanshu mumbai, maharashtra 6
244 seedtan 0
245 nobaiah143billa 0
246 saurav dhakal Nepal 0
247 Deep Narayan Rai 1
248 sajjad hussain 1
249 deepak chandra 2
250 Naresh Gorre 0
251 priyamaina assam india 1
252 goravsaini 1
253 sherlock 0
254 Nileshsingh 1
255 Aashiqurrahman 0
256 Anushka Singh 1
257 sumit chhari mumbai 1
258 waquarthakur Gulaothi 0
259 rama karki 1
260 pushpa 0
261 hasrat 0
262 pawan sharma 0
263 josey joo 0
264 govinda kr. yadav 0
265 gurnam singh 1
266 MyBusTickets.in India 216
267 vicarsonmilco 0
268 ANKIT GUPTA 0
269 alamin 0
270 Kishore 1
271 aifazz jr sayed 0
272 Salman khan 0
273 Dipesh Jha 0
274 premkumar 1
275 KD Rahees Saifi 2
276 Shafiq mastoi 0
277 Manvi Agarwal 1
278 sumit 1
279 manishkumar h patel 1
Error 88: Rate limit exceeded
Total: 300
280 ajay desai 0
281 Umang Pandita New Delhi 11
282 anu rathour 1
283 Srinivas Kamath 1
284 Pranay Gavhale 1
285 pranjal Guwahati 1
286 Nani_Tasser 0
287 Aryan siddiqui 0
288 Karina Noren 0
289 samyok subba 0
290 sajid malik 0
291 Ritesh kanwar 0
292 kameshnayak2 raipur 1
293 Ashik Babu 1
294 Jenifer Bubak 0
295 divyansh verma kanpur 53
296 Tothi Monsang Manipur, India. 0
297 vikas pathak 1
298 Mohit Rule 1
299 asgar ali 3
At last i can see a "Error 88: Rate limit exceeded" message.
Thanks.
At last i got solution for this. This is the only way i found,
Save the last cursor and sent this cursor after 15 minutes as first cursor. it will show another 300 followers.
Thanks
https://dev.twitter.com/docs/api/1.1/get/followers/ids
Technically, the limit of followers returned each request is 5000.
Are you sure that the count is really 300 in any cases ? Did you display the count of the list you have ?

Formatting raw text gathered from another website using php

I am trying to retrieve a table from another website, which is based on several variables passed to it via a form. I have worked out that the url details after the ? correspond to those variables and have created a form on my page to post those variables and create url, which I have then put into a file_get_contents process, whereby I collect the table as data (I have narrowed the get to the div in which the table is housed).
My problem is that the data is shown as a string of plain text on my page with no formatting (i.e. no columns or rows).
Here is the code to retrieve the data:
<?php
$page = file_get_contents($stats_url);
$doc = new DOMDocument();
$doc->loadHTML($page);
$divs = $doc->getElementsByTagName('div');
foreach($divs as $div) {
// Loop through the DIVs looking for one withan id of "content"
// Then echo out its contents (pardon the pun)
if ($div->getAttribute('id') === 'statstable') {
echo $div->nodeValue;
}
}
?>
Here is a sample of the data returned:
NameGamesInnsNot OutsRunsHigh ScoreAvg50's100'sDucksStrike RateBowled (%)Caught (%)LBW (%)Stumped (%)Run Out (%)Not Out (%)Did Not Bat (%)%Games Won%Games Drawn%Games Lost%Team RunsCatchesStumpingsRun OutsOwais Fareed 1 1 0 72 7272 1 0 0 - 0 1 (100) 0 0 0 0 0 0 0 100 42.6 0 0 0 Atif Ali 2 2 0 28 2814 0 0 1 - 2 (100) 0 0 0 0 0 0 0 0 100 11.62 0 0 0 Craig Hills 2 2 0 20 1310 0 0 0 - 0 1 (50) 1 (50) 0 0 0 0 0 0 100 8.3 1 0 0 Dale Skeath 2 2 0 16 128 0 0 0 - 1 (50) 1 (50) 0 0 0 0 0 0 0 100 6.64 1 0 0 ash ashim 2 2 1 16 10*16 0 0 0 - 0 1 (50) 0 0 0 1 (50) 0 0 0 100 6.64 0 0 0 Hussain Dalvi 1 1 0 11 1111 0 0 0 - 0 1 (100) 0 0 0 0 0 0 0 100 6.51 0 0 0 Azhar Ali 1 1 0 11 1111 0 0 0 - 0 1 (100) 0 0 0 0 0 0 0 100 6.51 0 0 0 A Hammed 1 1 0 10 1010 0 0 0 - 0 1 (100) 0 0 0 0 0 0 0 100 5.92 0 0 0 M Ali 1 1 0 5 55 0 0 0 - 1 (100) 0 0 0 0 0 0 0 0 100 2.96 0 0 0 Simon Pleasant 1 1 0 5 55 0 0 0 - 0 1 (100) 0 0 0 0 0 0 0 100 6.94 0 0 0
How can I then take this text and recompile it as a table?
Check out PHP Simple HTML DOM Parser
It works brilliantly for this stuff.
http://simplehtmldom.sourceforge.net/

Categories