在线观看不卡亚洲电影_亚洲妓女99综合网_91青青青亚洲娱乐在线观看_日韩无码高清综合久久

鍍金池/ 問答/ 人工智能問答
茍活 回答

一個爬蟲類就可以解決。

yield Request(URL,callback)返回第一次爬取的鏈接。

然后用callback函數(shù)對返回鏈接進行再次爬取,接著再對爬取數(shù)據(jù)處理給item或者繼續(xù)yield Request也行。

callback就是回調(diào)的函數(shù)名。

不用存文檔里,那樣速度太慢了。


例子:類似于這種,有點偽代碼。

class MySpider(scrapy.Spider):
    name = 'zhilian_spider'
    allowed_domains = ['example.com']
    start_urls = [
        'http://www.zhaopin.com/citymap.html']
    yield scrapy.Request(url, callback=self.parse)

    def parse(self, response):
        ...
        yield scrapy.Request(url, callback=self.parse_jobs, dont_filter=True)

    def parse_jobs(self, response):
        ...
            yield item

建議研究一下scrapy
官網(wǎng)內(nèi)容:http://scrapy-chs.readthedocs...

擱淺 回答

已解決

 def parse(self, response):
        li_list = response.css("div.list_cont.Left_list_cont.Left_list_cont1 > div.tab_tj > div > div > ul > li")
        url_list = []
        for li in li_list:
            item = CardItem()
            href = li.css("a::attr(href)").extract_first()
            item['href'] = href
            item['title'] = li.css("a::attr(title)").extract_first()
            url_list.append(href)
            yield item
        for i in url_list:
            print("->>> %s" % i)
            yield scrapy.Request(url=i, callback=self.detail_parse, headers=self.headers)
雨萌萌 回答
  1. 可以先通過bash命令mongoexport把mongo里的數(shù)據(jù)導(dǎo)出成文件,然后通過讀取文件內(nèi)容來處理
  2. data = list(col.find({'id': {"$in": nodes}})) 直接加載到內(nèi)存試一下?id字段加索引了吧?
不討喜 回答

沒有css,無法確定你的問題。
應(yīng)該是這個div的外層結(jié)點有width限制了。

萢萢糖 回答

我完全復(fù)制粘貼了你的代碼。。并沒有發(fā)生你所截圖的情況。

clipboard.png

另外 你這注釋的方式。。在template里不是應(yīng)該遵循h(huán)tml的注釋方式么。你看我這圖里你的注釋都被當成text輸出了。所以你這構(gòu)建環(huán)境具體怎么樣的和vue版本、package乃至開發(fā)工具都最好貼出來給大家參詳 避免玄學(xué)問題。。

安淺陌 回答

大概看懂了,你的意思是如果去匹配出來,只有少于或等于兩個字符不能匹配上,就算找到了是吧,我把條件列一下

import re

if re.match(r'^.{0,6}首長四方財務(wù)有限公司$', '北京首長四方財務(wù)有限公司') or re.match(r'^首長四方財務(wù)有限公司.{0,6}$', '北京首長四方財務(wù)有限公司')
    ......

用.{0,6}判定首尾最多6個字符不匹配上,其中1個漢字占3個字符。

希望能幫助到你。

小曖昧 回答

js所在頁和你接口地址,不是跨域關(guān)系吧?如果是跨域的話,jq是會發(fā)起兩次請求的,一次是 OPTION ,一次是 POST 。


題外話,你redis用的是string,也不是不行,就是到時候會有多少個key你自己管理起來會累死,而且也不好做關(guān)鍵詞排名,推薦哈希集或者有序集合

任她鬧 回答

kafka里面有單播和廣播的區(qū)別,對一條消息來說,同一個消費組內(nèi)的消費者有競態(tài)關(guān)系,只有一個消費者能消費,這個是單播;同樣,對一條消息,不同消費組的消費者都可以同時消費,這是多播。假如你想讓兩個消費者都能同時消費到消息,你可以將這兩個消費者放在不同的消費組,這個需要消費端的groupId屬性來設(shè)置。

陌上花 回答

問題解決了。直接將core-site.xml文件拷貝到classpath下,或者添加如下配置即可:

conf.set("hadoop.tmp.dir", "/home/parallels/app/hadoop-2.4.1/data/");
病癮 回答

內(nèi)存問題可以使用valgrind定位。
“double free”或者“Segmentation fault” 要給出具體異常信息,光給個代碼片段沒什么用

瘋浪 回答

Django models支持abstract=True屬性, 設(shè)置這個屬性后, 這個models不會在創(chuàng)建表, 專門用來繼承, 具體的可以看官方文檔 Models Abstract base classes部分.

Abstract base classes

Abstract base classes are useful when you want to put some common information into a number of other models. You write your base class and put abstract=True in the Meta class. This model will then not be used to create any database table. Instead, when it is used as a base class for other models, its fields will be added to those of the child class. It is an error to have fields in the abstract base class with the same name as those in the child (and Django will raise an exception).

An example:

from django.db import models

class CommonInfo(models.Model):
    name = models.CharField(max_length=100)
    age = models.PositiveIntegerField()

    class Meta:
        abstract = True

class Student(CommonInfo):
    home_group = models.CharField(max_length=5)

The Student model will have three fields: name, age and home_group. The CommonInfo model cannot be used as a normal Django model, since it is an abstract base class. It does not generate a database table or have a manager, and cannot be instantiated or saved directly.

熊出沒 回答

實現(xiàn)key-value咯,參見https://www.zhihu.com/question/30527705

當然時間多的話你可以對比各種查找樹實現(xiàn)key-value存儲結(jié)構(gòu)的存儲和查詢效率,搞個benchmark,然后就可以寫一篇博客。

糖豆豆 回答

自問自答,結(jié)束

懶洋洋 回答

不一定越多越好,建議你看看這個。這個回答比較專業(yè),提到了層數(shù)和節(jié)點數(shù)量的關(guān)系。
神經(jīng)網(wǎng)絡(luò)如何選擇隱藏層的數(shù)量

葬愛 回答

不知道ab.exe測試時什么原理,你自己寫一個多線程調(diào)用下就知道了會產(chǎn)生負數(shù)值的。

//php不會,用java寫了個test。
import redis.clients.jedis.Jedis;


public class Test {
    
    public static void main(String[] args) throws Exception {
        
        Jedis jedis = getJedis();
        jedis.set("nums", 50+"");
        close(jedis);
        
        for(int i = 0;i < 1000;i++){ //啟動1000個線程
            new Thread(new MyTask()).start();
        }
        
    }
    
    public static  Jedis getJedis(){
        Jedis j = new Jedis("xxxxx", 6379);
        j.auth("xxxx");
        return j;
    }
    
    public static void close(Jedis jedis){
        if(null == jedis){
            return;
        }
        jedis.close();
    }
}

class MyTask implements Runnable{
    @Override
    public void run() {
        Jedis j = Test.getJedis();
         String numStr = j.get("nums");
         Integer nums = Integer.valueOf(numStr);
        
        if(nums > 1){
             j.decr("nums");
        }else{
             System.out.println(nums);
        }
        Test.close(j);
    }
}

輸出結(jié)果出現(xiàn)負值。

胭脂淚 回答

google 了一晚上,終于找到了比較滿意的方法,下面是整個的 RedisCacheConfig 文件

@Configuration
public class RedisCacheConfig {

    @Bean
    public KeyGenerator simpleKeyGenerator() {
        return (o, method, objects) -> {
            StringBuilder stringBuilder = new StringBuilder();
            stringBuilder.append(o.getClass().getSimpleName());
            stringBuilder.append(".");
            stringBuilder.append(method.getName());
            stringBuilder.append("[");
            for (Object obj : objects) {
                stringBuilder.append(obj.toString());
            }
            stringBuilder.append("]");

            return stringBuilder.toString();
        };
    }

    @Bean
    public CacheManager cacheManager(RedisConnectionFactory redisConnectionFactory) {
        return new RedisCacheManager(
            RedisCacheWriter.nonLockingRedisCacheWriter(redisConnectionFactory),
            this.getRedisCacheConfigurationWithTtl(600), // 默認策略,未配置的 key 會使用這個
            this.getRedisCacheConfigurationMap() // 指定 key 策略
        );
    }

    private Map<String, RedisCacheConfiguration> getRedisCacheConfigurationMap() {
        Map<String, RedisCacheConfiguration> redisCacheConfigurationMap = new HashMap<>();
        redisCacheConfigurationMap.put("UserInfoList", this.getRedisCacheConfigurationWithTtl(3000));
        redisCacheConfigurationMap.put("UserInfoListAnother", this.getRedisCacheConfigurationWithTtl(18000));

        return redisCacheConfigurationMap;
    }

    private RedisCacheConfiguration getRedisCacheConfigurationWithTtl(Integer seconds) {
        Jackson2JsonRedisSerializer<Object> jackson2JsonRedisSerializer = new Jackson2JsonRedisSerializer<>(Object.class);
        ObjectMapper om = new ObjectMapper();
        om.setVisibility(PropertyAccessor.ALL, JsonAutoDetect.Visibility.ANY);
        om.enableDefaultTyping(ObjectMapper.DefaultTyping.NON_FINAL);
        jackson2JsonRedisSerializer.setObjectMapper(om);

        RedisCacheConfiguration redisCacheConfiguration = RedisCacheConfiguration.defaultCacheConfig();
        redisCacheConfiguration = redisCacheConfiguration.serializeValuesWith(
            RedisSerializationContext
                .SerializationPair
                .fromSerializer(jackson2JsonRedisSerializer)
        ).entryTtl(Duration.ofSeconds(seconds));

        return redisCacheConfiguration;
    }
}

要指定 key 的過期時間,只要在getRedisCacheConfigurationMap方法中添加就可以。
然后只需要 @Cacheable 就可以把數(shù)據(jù)存入 redis

    @Cacheable(value = "UserInfoList", keyGenerator = "simpleKeyGenerator") // 3000秒
    @Cacheable(value = "UserInfoListAnother", keyGenerator = "simpleKeyGenerator") // 18000秒
    @Cacheable(value = "DefaultKeyTest", keyGenerator = "simpleKeyGenerator") // 600秒,未指定的key,使用默認策略
    
夢囈 回答

clipboard.png

一般都是這樣實現(xiàn) 你可以參考下

礙你眼 回答

可以下個有道云筆記,新建一個markdown格式的筆記,以后任何markdown相關(guān)的操作都可以在有道上做實驗。
有道上把所有操作都以圖形化界面的方式展示出來了

clipboard.png

然后回答問題復(fù)制一下代碼把url替換掉就可以插入圖片了

![image](http://note.youdao.com/favicon.ico)

順便推薦一個圖床網(wǎng)站,可以將本地圖片上傳到服務(wù)器
Z4圖床