fgetcsv()
и работать с маленькими объёмами данных.ALTER TABLE xxx ADD INDEX(ID)
.INSERT
используя INSERT IGNORE
.$file = 'result.xlsx';
header('Content-Type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet');
header('Content-Disposition: attachment; filename="result.xlsx"');
header('Cache-Control: max-age=0');
header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
header('Cache-Control: cache, must-revalidate');
header('Pragma: public');
header('Content-Length: ' . filesize($file));
readfile($file);
function remove_files( $dirname ) {
$type = array( 'jpg', 'jpeg', 'png' );
if ( is_dir($dirname) ) { $dir_handle = opendir( $dirname ); }
if ( !$dir_handle ) { return false; }
while( $file = readdir( $dir_handle ) ) {
$ext = explode( '.', $file );
if( !in_array( end( $ext ), $type ) ) { continue; }
if ( $file != '.' && $file != '..' && !is_dir( $dirname . '/' . $file )) {
unlink( $dirname . '/' . $file );
}
}
closedir($dir_handle);
return true;
}
remove_files( '/usr/share/nginx/html/upload' );
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_USERAGENT, "GOOGLE"); // Обманочка
curl_setopt($ch, CURLOPT_HEADER, 0);
$output = curl_exec($ch);
echo '<pre>';
print_r( curl_getinfo($ch) );
echo '</pre>';
curl_close($ch);
echo $output;
Array
(
[url] => https://soccer365.ru/games/921770/
[content_type] => text/html; charset=UTF-8
[http_code] => 301
[header_size] => 539
[request_size] => 84
[filetime] => -1
[ssl_verify_result] => 0
[redirect_count] => 0
[total_time] => 0.255368
[namelookup_time] => 0.000614
[connect_time] => 0.02999
[pretransfer_time] => 0.19802
[size_upload] => 0
[size_download] => 0
[speed_download] => 0
[speed_upload] => 0
[download_content_length] => 0
[upload_content_length] => 0
[starttransfer_time] => 0.25531
[redirect_time] => 0
[redirect_url] => https://soccer365.ru//soccer365.ru/live/match-etyir-1924-levski-smotret-onlayn/
[primary_ip] => 51.15.25.134
[certinfo] => Array
(
)
)
<?php
//define('STDOUT', fopen('debug_log.txt', 'wb')); //write console logs to file
use JonnyW\PhantomJs\Client;
$url = 'https://toster.ru';
$client = Client::getInstance();
//$client->getEngine()->debug(true); //enable debug
$request = $client->getMessageFactory()->createCaptureRequest($url);
$response = $client->getMessageFactory()->createResponse();
$request->setOutputFile( 'preview.png' );
$request->setViewportSize(500, 1500); //width, height
//$request->setCaptureDimensions(500, 645, 0, 0); //width, height, top, left
$request->setFormat('png');
$request->setQuality(100);
$request->setTimeout(5000); // will render page if this timeout is reached and resources haven't finished loading
$client->send($request, $response);
$image = imagecreatefrompng( 'preview.png' );
$image = imagecropauto( $image, IMG_CROP_WHITE );
imagepng( $image, 'croped_preview.png' );
imagedestroy( $image );
from selenium import webdriver
driver = webdriver.Chrome('/usr/local/bin/chromedriver')
driver.set_window_position(0, 0)
driver.set_window_size(500, 1500)
driver.get('https://toster.ru')
screenshot = driver.save_screenshot('/users/Pavel/Desktop/preview.png')
convert template_bolts.png +level-colors #FF0000, ready_bolts.png
convert -append ready_*.png final_image.png
<?php
$ch = curl_init();
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
import ssl
try:
_create_unverified_https_context = ssl._create_unverified_context
except AttributeError:
pass
else:
ssl._create_default_https_context = _create_unverified_https_context
$arrXcount = count($arrX);
$arrYcount = count($arrY);
for ($a = 0; $a < $iter; $a++) {
for ($i = 0; $i < $arrXcount; $i++) {
for ($j = 0; $j < $arrYcount; $j++) {
...
}
}
}
if ($value % 2 == 0) {
$total = $total + 1;
}
if ($value % 2 != 0) {
$total = $total + 2;
}
if ($value % 2 == 0) {
$total = $total + 1;
} else {
$total = $total + 2;
}
echo "Total: $total";
echo "<br>Script time is $time";
echo 'Total: ' . $total;
echo '<br>Script time is ' . $time;
<form action="post_create.php" method="post" enctype="multipart/form-data">
<input type="text" name="title">
<input type="text" name="tags">
<input type="text" name="text">
<input type="file" name="pic">
<input type="submit" name="submit" value="Submit">
</form>
$extracted_plaintext = mb_convert_encoding( $extracted_plaintext, 'UTF-8', 'UTF-16LE' );
function read_doc_file($filename) {
if (file_exists($filename)) {
if (($fh = fopen($filename, 'r')) !== false) {
$headers = fread($fh, 0xA00);
// 1 = (ord(n)*1) ; Document has from 0 to 255 characters
$n1 = ( ord($headers[0x21C]) - 1 );
// 1 = ((ord(n)-8)*256) ; Document has from 256 to 63743 characters
$n2 = ( ( ord($headers[0x21D]) - 8 ) * 256 );
// 1 = ((ord(n)*256)*256) ; Document has from 63744 to 16775423 characters
$n3 = ( ( ord($headers[0x21E]) * 256 ) * 256 );
// 1 = (((ord(n)*256)*256)*256) ; Document has from 16775424 to 4294965504 characters
$n4 = ( ( ( ord($headers[0x21F]) * 256 ) * 256 ) * 256 );
// Total length of text in the document
$textLength = ($n1 + $n2 + $n3 + $n4);
$extracted_plaintext = fread($fh, $textLength);
$extracted_plaintext = mb_convert_encoding( $extracted_plaintext, 'UTF-8', 'UTF-16LE' );
return nl2br($extracted_plaintext);
} else {
return FALSE;
}
} else {
return FALSE;
}
}
$text = read_doc_file('test.doc');
$text = "A strange string ø, æ, å, ж, п, ą, ū, ė, …";
foreach(mb_list_encodings() as $chr){
echo mb_convert_encoding( $text, 'UTF-8', $chr ) . " : " . $chr . "<br><br>";
}
var FeedParser = (function() {
function FeedParser(Feed_Table_StatsParser) {
this.DELIMITER_ROW = "~";
this.DELIMITER_CELL = "¬";
this.DELIMITER_VALUE = "÷";
this.statsParser = Feed_Table_StatsParser
}
FeedParser.prototype.parse = function(feed) {
var statsParser = this.statsParser;
statsParser.startFeed();
var rows = feed.split(this.DELIMITER_ROW);
for (var _i = 0, rows_1 = rows; _i < rows_1.length; _i++) {
var row = rows_1[_i];
statsParser.startRow();
var cells = row.split(this.DELIMITER_CELL);
for (var _a = 0, cells_1 = cells; _a < cells_1.length; _a++) {
var cell = cells_1[_a];
var keyValue = cell.split(this.DELIMITER_VALUE);
statsParser.parse(keyValue[0], keyValue[1])
}
statsParser.endRow()
}
statsParser.endFeed();
return statsParser.getParsedModel()
};
return FeedParser
}());