PHP Warning: mysqli_query(): (HY000/1030): Got error 28 from storage engine in /home/ftp/u/umxopinm/wwwroot/wp-includes/wp-db.php on line 2033 WordPress数据库查询SELECT t.*, tt.* FROM wp_terms AS t INNER JOIN wp_term_taxonomy AS tt ON t.term_id = tt.term_id INNER JOIN wp_term_relationships AS tr ON tr.term_taxonomy_id = tt.term_taxonomy_id WHERE tt.taxonomy IN ('category') AND tr.object_id IN (561) ORDER BY t.name ASC 时发生Got error 28 from storage engine错误,这是由require('wp-blog-header.php'), require_once('wp-includes/template-loader.php'), include('/themes/shapely/page-templates/full-width.php'), get_header, locate_template, load_template, require_once('/themes/shapely/header.php'), wp_head, do_action('wp_head'), WP_Hook->do_action, WP_Hook->apply_filters, adjacent_posts_rel_link_wp_head, adjacent_posts_rel_link, get_adjacent_post_rel_link, get_permalink, get_the_category, get_the_terms, wp_get_object_terms, get_terms, WP_Term_Query->query, WP_Term_Query->get_terms查询的 PHP Warning: mysqli_query(): (HY000/1030): Got error 28 from storage engine in /home/ftp/u/umxopinm/wwwroot/wp-includes/wp-db.php on line 2033 WordPress数据库查询SELECT t.*, tt.* FROM wp_terms AS t INNER JOIN wp_term_taxonomy AS tt ON t.term_id = tt.term_id INNER JOIN wp_term_relationships AS tr ON tr.term_taxonomy_id = tt.term_taxonomy_id WHERE tt.taxonomy IN ('category') AND tr.object_id IN (805) ORDER BY t.name ASC 时发生Got error 28 from storage engine错误,这是由require('wp-blog-header.php'), require_once('wp-includes/template-loader.php'), include('/themes/shapely/page-templates/full-width.php'), get_header, locate_template, load_template, require_once('/themes/shapely/header.php'), wp_head, do_action('wp_head'), WP_Hook->do_action, WP_Hook->apply_filters, adjacent_posts_rel_link_wp_head, adjacent_posts_rel_link, get_adjacent_post_rel_link, get_permalink, get_the_category, get_the_terms, wp_get_object_terms, get_terms, WP_Term_Query->query, WP_Term_Query->get_terms查询的

Codes

Codes

Web Crawler for Images

Python Codes:

# coding:utf-8
import os
import re
import urllib
import json
import socket
import urllib.request
import urllib.parse
import urllib.error
import time

timeout = 5
socket.setdefaulttimeout(timeout)

class Crawler:
    __time_sleep = 0.1      # sleeping time
    __amount = 0
    __start_amount = 0
    __counter = 0
    headers = {'User-Agent': 'Mozilla/5.0 (Windows NT 6.1; WOW64; rv:23.0) Gecko/20100101 Firefox/23.0'}       
    # get the url imformation of pirctures
    def __init__(self, t=0.1):
        self.time_sleep = t     # download intervals
    # get suffix name of the pictures
    def get_suffix(self, name):     
        m = re.search(r'\.[^\.]*$', name)
        if m.group(0) and len(m.group(0)) <= 5:
            return m.group(0)
        else:
            return '.jpg'
    # get and generate referrer
    def get_referrer(self, url):        
        par = urllib.parse.urlparse(url)
        if par.scheme:
            return par.scheme + '://' + par.netloc
        else:
            return par.netloc
    def save_image(self, rsp_data, word):        # save images
        if not os.path.exists("./" + word):
            os.mkdir("./" + word)
        self.__counter = len(os.listdir('./' + word)) + 1
        for image_info in rsp_data['imgs']:
            try:
                time.sleep(self.time_sleep)
                suffix = self.get_suffix(image_info['objURL'])            
                refer = self.get_referrer(image_info['objURL'])  # reduce 403 error
                opener = urllib.request.build_opener()
                opener.addheaders = [('User-agent', 'Mozilla/5.0 (Windows NT 10.0; WOW64; rv:55.0) Gecko/20100101 Firefox/55.0'),('Referer', refer)]
                urllib.request.install_opener(opener)
                urllib.request.urlretrieve(image_info['objURL'], './' + word + '/' + str(self.__counter) + str(suffix))
            except urllib.error.HTTPError as urllib_err:
                print(urllib_err)
                continue
            except Exception as err:
                time.sleep(1)
                print(err)
                print("unknown error, cancel operations")
                continue
            else:
                print("figure+1, there is already" + str(self.__counter) + "figures")
                self.__counter += 1
        return
    def get_images(self, word='beautiful girls'):
        search = urllib.parse.quote(word)
        pn = self.__start_amount    
        while pn < self.__amount:
            url = 'http://image.baidu.com/search/avatarjson?tn=resultjsonavatarnew&amp;ie=utf-8&amp;word=' + search + '&amp;cg=girl&amp;pn=' + str(
                pn) + '&amp;rn=60&amp;itg=0&amp;z=0&amp;fr=&amp;width=&amp;height=&amp;lm=-1&amp;ic=0&amp;s=0&amp;st=-1&amp;gsm=1e0000001e'
            try:
                time.sleep(self.time_sleep)
                req = urllib.request.Request(url=url, headers=self.headers)
                page = urllib.request.urlopen(req)
                rsp = page.read().decode('unicode_escape')
                page.close()
            except UnicodeDecodeError as e:
                print(e)
                print('-----UnicodeDecodeErrorurl:', url)
            except urllib.error.URLError as e:
                print(e)
                print("-----urlErrorurl:", url)
            except socket.timeout as e:
                print(e)
                print("-----socket timout:", url)
            else:                
                rsp_data = json.loads(rsp)  
                self.save_image(rsp_data, word)
                print("download the next page")
                pn += 60
            finally:
                page.close()
        print("Finished")
        return
    def start(self, word, spider_page_num=1, start_page=1):
        """
        web crawl entrance
        :param word: key words
        :param spider_page_num: the pages for catching pictures; the total picture number is page_num x 60
        :param start_page: start page
        :return:
        """
        self.__start_amount = (start_page - 1) * 60
        self.__amount = spider_page_num * 60 + self.__start_amount
        self.get_images(word)

if __name__ == '__main__':
    crawler = Crawler(0.05)  # delay time: 0.05
    # crawler.start('beautiful girls', 10, 2)  # key word: "beautiful girls", 10 pages (totally 10x60=600 pictures), the start papge is page 2
    # crawler.start("actors", 5, 3)  # key word: "actors", 5 pages (totally 5x60=300 pictures), the start papge is page 1

PHP Warning: mysqli_query(): (HY000/1030): Got error 28 from storage engine in /home/ftp/u/umxopinm/wwwroot/wp-includes/wp-db.php on line 2033 WordPress数据库查询SELECT t.*, tt.*, tr.object_id FROM wp_terms AS t INNER JOIN wp_term_taxonomy AS tt ON t.term_id = tt.term_id INNER JOIN wp_term_relationships AS tr ON tr.term_taxonomy_id = tt.term_taxonomy_id WHERE tt.taxonomy IN ('category', 'post_tag', 'post_format') AND tr.object_id IN (812, 815, 819, 825) ORDER BY t.name ASC 时发生Got error 28 from storage engine错误,这是由require('wp-blog-header.php'), require_once('wp-includes/template-loader.php'), include('/themes/shapely/page-templates/full-width.php'), get_template_part, locate_template, load_template, require('/themes/shapely/template-parts/content.php'), do_action('shapely_single_after_article'), WP_Hook->do_action, WP_Hook->apply_filters, Shapely_Related_Posts->output_related_posts, Shapely_Related_Posts->get_related_posts, WP_Query->__construct, WP_Query->query, WP_Query->get_posts, _prime_post_caches, update_post_caches, update_object_term_cache, wp_get_object_terms, get_terms, WP_Term_Query->query, WP_Term_Query->get_terms查询的 PHP Warning: mysqli_query(): (HY000/1030): Got error 28 from storage engine in /home/ftp/u/umxopinm/wwwroot/wp-includes/wp-db.php on line 2033 WordPress数据库查询SELECT t.*, tt.*, tr.object_id FROM wp_terms AS t INNER JOIN wp_term_taxonomy AS tt ON t.term_id = tt.term_id INNER JOIN wp_term_relationships AS tr ON tr.term_taxonomy_id = tt.term_taxonomy_id WHERE tt.taxonomy IN ('category', 'post_tag', 'post_format') AND tr.object_id IN (805) ORDER BY t.name ASC 时发生Got error 28 from storage engine错误,这是由require('wp-blog-header.php'), require_once('wp-includes/template-loader.php'), include('/themes/shapely/page-templates/full-width.php'), get_template_part, locate_template, load_template, require('/themes/shapely/template-parts/content.php'), do_action('shapely_single_after_article'), WP_Hook->do_action, WP_Hook->apply_filters, Shapely_Related_Posts->output_related_posts, Shapely_Related_Posts->get_related_posts, WP_Query->__construct, WP_Query->query, WP_Query->get_posts, update_post_caches, update_object_term_cache, wp_get_object_terms, get_terms, WP_Term_Query->query, WP_Term_Query->get_terms查询的
Kathleen Li

发表评论

电子邮件地址不会被公开。 必填项已用*标注