Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!DOCTYPE html>
- <html lang="en">
- <head>
- <meta charset="UTF-8">
- <title>Document</title>
- </head>
- <body>
- <?php
- include 'simple_html_dom.php';
- $db = mysqli_connect('localhost', 'mysql', 'mysql', 'sshmarket');
- if (mysqli_connect_errno()) {
- printf("Connection error: %s\n", mysqli_connect_error());
- exit();
- }
- $site = 'http://optnow.ru/catalog';
- $data = file_get_html($site);
- $catalogLink = array();
- $i = 0;
- if(!empty($data)) {
- foreach($data->find('div.cat-name a') as $catalog) {
- $catalogLink['url'] = $catalog->href;
- $urls[] = $catalogLink;
- }
- foreach($urls as $url => $k) {
- foreach($k as $n) {
- $catalogLink = 'http://optnow.ru/' . $n . '?page=0';
- $productData = file_get_html($catalogLink);
- foreach($productData->find('.link-pv-name') as $link) {
- $productLink['url'] = $link->href;
- $productUrls[] = $productLink;
- }
- foreach($productUrls as $href) {
- $link = 'http://optnow.ru/' . $href['url'];
- $product = file_get_html($link);
- foreach($product->find('.block-d .btns-d .btn-buy') as $productId) {
- if(!empty($productId)) {
- $dataId = $productId->{'data-offerid'};
- print_r($dataId);
- }
- }
- foreach($product->find('.description div div p') as $description) {
- if(!empty($description)) {
- $query = "UPDATE snowcore_parser_products SET description = '0' WHERE remote_id = " . $dataId . " ';";
- $sql = mysqli_query($db, $query);
- print_r($sql);
- }
- }
- }
- }
- }
- }
- ?>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement