鍍金池/ 問答/ 數據分析&挖掘問答
囍槑 回答

https代理在建立代理隧道之后只需要轉發(fā)原始報文就好了,這樣做代理服務器并不能拿到https明文,而中間人攻擊是能拿到明文的
可以看看https://segmentfault.com/a/11...

櫻花霓 回答

把<p>里面的內容整個提取出string來后用re提取。

r'\<br\>([\w\/]+)$'

clipboard.png

鐧簞噯 回答

漏了theme(),犯了個2b錯誤。。。

陪她鬧 回答

找到問題了,網頁用Angular動態(tài)加載的,爬蟲爬取的時候都是空的,就報錯咯~~

笑忘初 回答
let result = arr2.filter((v, i)=>arr1[i] && /\D/.test(arr1[i]));
console.log(result);
我以為 回答

你可能需要先去一個醫(yī)學庫,把所有的疾病名稱都獲取到。然后用疾病名稱去搜索。

青瓷 回答

找到原因了,還需要重寫GetContextMenuHandler接口。

virtual CefRefPtr<CefContextMenuHandler> SimpleHandler::GetContextMenuHandler() 
        OVERRIDE {
    return this;
}
瘋浪 回答

沒想到SF有Haskell問題:)

其實你看Profiling的結果,in_rangeinherited %timeinherited %alloc都比larger_than大,占了整個程序執(zhí)行的100%和93.3%。所以第一種方法快。

寫個rewrite rule也許可以對elemenumFromTo進行優(yōu)化。

試了寫rewrite rule,發(fā)現(xiàn)enumFromTo有inline,導致rewrite rule沒有生效,所以先自己實現(xiàn)一個myEnumFromTo看看效果:

module Main where

{-# RULES
   "elem/myEnumFromTo" forall (x::Integer) (n::Integer) (m::Integer) . elem x (myEnumFromTo n m) = x >= n && x <= m 
#-}

{-# NOINLINE myEnumFromTo #-}
myEnumFromTo n m
  | n == m = [n]
  | otherwise = [n] ++ myEnumFromTo (n + 1) m

main = do
  print $ {-# SCC larger_than  #-} lth 100000000
  print $ {-# scc in_range #-} inr     100000000

lth :: Integer -> Bool
lth x = (x >= 1 && x <= 65535000000000)

inr :: Integer -> Bool
inr x = let m = 65535000000000::Integer in
  x `elem` (myEnumFromTo 1 m)

Profile結果是這樣的:

main        Main             app/Main.hs:(12,1)-(14,48)    0.0   15.8


                                                                                   individual      inherited
COST CENTRE    MODULE                SRC                        no.     entries  %time %alloc   %time %alloc

MAIN           MAIN                  <built-in>                 144          0    0.0   29.6     0.0  100.0
 CAF           GHC.Conc.Signal       <entire-module>            252          0    0.0    0.9     0.0    0.9
 CAF           GHC.IO.Encoding       <entire-module>            241          0    0.0    3.8     0.0    3.8
 CAF           GHC.IO.Encoding.Iconv <entire-module>            239          0    0.0    0.3     0.0    0.3
 CAF           GHC.IO.Handle.FD      <entire-module>            231          0    0.0   47.3     0.0   47.3
 CAF           GHC.IO.Handle.Text    <entire-module>            229          0    0.0    0.1     0.0    0.1
 CAF           GHC.Show              <entire-module>            214          0    0.0    0.4     0.0    0.4
 CAF           GHC.Event.Thread      <entire-module>            193          0    0.0    1.7     0.0    1.7
 CAF           GHC.Event.Poll        <entire-module>            160          0    0.0    0.1     0.0    0.1
 CAF:main1     Main                  <no location info>         286          0    0.0    0.0     0.0    0.0
  main         Main                  app/Main.hs:(12,1)-(14,48) 288          1    0.0    0.0     0.0    0.0
 CAF:main2     Main                  <no location info>         284          0    0.0    0.0     0.0    0.0
  main         Main                  app/Main.hs:(12,1)-(14,48) 293          0    0.0    0.0     0.0    0.0
   in_range    Main                  app/Main.hs:14:32-48       294          1    0.0    0.0     0.0    0.0
    inr        Main                  app/Main.hs:(20,1)-(21,29) 295          1    0.0    0.0     0.0    0.0
     inr.m     Main                  app/Main.hs:20:13-39       296          1    0.0    0.0     0.0    0.0
 CAF:main4     Main                  <no location info>         285          0    0.0    0.0     0.0    0.0
  main         Main                  app/Main.hs:(12,1)-(14,48) 290          0    0.0    0.0     0.0    0.0
   larger_than Main                  app/Main.hs:13:36-48       291          1    0.0    0.0     0.0    0.0
    lth        Main                  app/Main.hs:17:1-39        292          1    0.0    0.0     0.0    0.0
 main          Main                  app/Main.hs:(12,1)-(14,48) 289          0    0.0   15.8     0.0   15.8

還不知道怎讓才能對enumFromTo生效:(

毀憶 回答

geojson 可以轉化成平面多邊形數據,然后你平均分布的點可以依次跟這個多邊形對比。

孤星 回答

nextDelivery.rows.map(row => console.log(row.id))

咕嚕嚕 回答

并不是每個代理IP都有效,你要先確認代理是否有效再去使用

import requests
from pyquery import PyQuery as Q

headers = {'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/65.0.3325.181 Safari/537.36'}
proxies = {
    "http": "http://103.235.245.35:8080"
}

r = requests.get('http://hz.xiaozhu.com/', headers=headers, proxies=proxies)
for _ in Q(r.text)('#page_list li'):
    title = Q(_).find('.result_title').text()
    price = Q(_).find('.result_price').text()

    print title, price
尐飯團 回答

plt是別的變量吧,試試在出錯一行上面加上

import matplotlib.pyplot as plt
兔寶寶 回答
$arr = array(
        array('id'=>'1','name'=>'a'),
        array('id'=>'1','name'=>'b'),
        array('id'=>'1','name'=>'c'),
        array('id'=>'2','name'=>'d'),
        array('id'=>'2','name'=>'e'),
    );
    
    
    $result = array();
    
    foreach ($arr as $value) {
        $result[$value['id']]['id'] = $value['id'];
        $result[$value['id']]['name'][] = $value['name'];
    }
    $result = array_values($result);
    print_r($result);

函數自己封裝吧

兔囡囡 回答

下載的SDK文件中的config配置參數沒有改,改成自己的微信參數就OK了

艷骨 回答

MySQL8在這里和低版本不兼容,你可以重新安裝MySQL(或者用Reconfigure選項),把認證的選項設置為“Use Legacy Authentication Method”, 或者你如果不是必須要用MySQL 8,可以降級到低版本。

枕邊人 回答

參考官方文檔

public static ExecutorService newFixedThreadPool(int nThreads)
創(chuàng)建一個線程池, 在重用共享無界隊列中運行的固定線程數。在任何時候, nThreads 個線程都將是活動的處理任務。如果在所有線程都處于活動狀態(tài)時提交了其他任務, 則它們將在隊列中等待, 直到線程可用為止。如果由于在關閉前執(zhí)行過程中出現(xiàn)故障而終止了任何線程, 則如果需要執(zhí)行后續(xù)任務, 則新項將取代它。池中的線程將存在, 直到顯式關閉為止。

可以用下面的程序測試

import java.util.concurrent.Executors;
import java.util.concurrent.ExecutorService;

public class ThreadPoolTest1 {
    
    static class MyTask implements Runnable {
        private String name;
        
        public MyTask(String name){
            this.name = name;
        }

        
        @Override
        public void run() {
            for (int i = 0; i < 2; i++) {
                // 做點事情
                try {
                    Thread.sleep(100);
                    if(System.currentTimeMillis() % 3 == 0 ){
                         System.out.println("stop!");
                         throw  new RuntimeException("break!"); //(1)注釋掉這一行將只有兩個Thread!
                    }
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
                System.out.println(name + " said:" + i+" Thread="+Thread.currentThread().getName());
            }
        }
    }

    
    public static void main(String[] args) {
        // 創(chuàng)建線程池
//        ExecutorService threadPool = Executors.newSingleThreadExecutor();
        ExecutorService threadPool = Executors.newFixedThreadPool(2);
//        ExecutorService threadPool = Executors.newCachedThreadPool();

        
        // 向線程池里面扔任務
        for (int i = 0; i < 10; i++) {
            threadPool.execute(new MyTask("Task" + i));
        }

        
        // 關閉線程池
        threadPool.shutdown();
    }
}

注釋掉(1)處的異常會得到正常結果

Task0 said:0 Thread=pool-1-thread-1
Task1 said:0 Thread=pool-1-thread-2
Task0 said:1 Thread=pool-1-thread-1
Task1 said:1 Thread=pool-1-thread-2
Task2 said:0 Thread=pool-1-thread-1
Task3 said:0 Thread=pool-1-thread-2
Task2 said:1 Thread=pool-1-thread-1
Task3 said:1 Thread=pool-1-thread-2
......

任務將在thread 1和2之間切換
拋出異常RuntimeException會看到如下的情況:

.......
java.lang.RuntimeException: break!
    at ThreadPoolTest1$MyTask.run(ThreadPoolTest1.java:22)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
    at java.lang.Thread.run(Thread.java:748)
Task4 said:0 Thread=pool-1-thread-5
Task5 said:0 Thread=pool-1-thread-6
......

能看到線程池在不斷創(chuàng)建新的線程.

入她眼 回答

emmm...哪里出現(xiàn)了2^n??...

擱淺 回答

你覺得你表達清楚了嗎?

真難過 回答

sea.distplot(x,hist_kws=dict(edgecolor='k'))