偷偷摘套内射激情视频,久久精品99国产国产精,中文字幕无线乱码人妻,中文在线中文a,性爽19p

手把手教你寫網(wǎng)絡(luò)爬蟲(chóng)(7):URL去重

開(kāi)發(fā) 后端
本期我們來(lái)聊聊URL去重那些事兒。以前我們?cè)褂肞ython的字典來(lái)保存抓取過(guò)的URL,目的是將重復(fù)抓取的URL去除,避免多次抓取同一網(wǎng)頁(yè)。

本系列:

[[230068]]

[[230069]]

IPv6編碼地址數(shù):2^128(約3.4×10^38)

IPv6是IETF設(shè)計(jì)的用于替代現(xiàn)行版本IP協(xié)議(IPv4)的下一代IP協(xié)議,號(hào)稱可以為全世界的每一粒沙子編上一個(gè)網(wǎng)址。

[[230070]]

 

  1. public <T> boolean put(T object, Funnel<? super T> funnel, int numHashFunctions, BitArray bits) {  
  2.     long bitSize = bits.bitSize();  
  3.     long hash64 = Hashing.murmur3_128().hashObject(object, funnel).asLong();  
  4.     int hash1 = (int) hash64;  
  5.     int hash2 = (int) (hash64 >>> 32);   
  6.  
  7.     boolean bitsChanged = false 
  8.     for (int i = 1; i <= numHashFunctions; i++) {  
  9.         int combinedHash = hash1 + (i * hash2);  
  10.         // Flip all the bits if it's negative (guaranteed positive number)  
  11.         if (combinedHash < 0) {  
  12.             combinedHash = ~combinedHash;  
  13.         }  
  14.         bitsChanged |= bits.set(combinedHash % bitSize);  
  15.     }  
  16.     return bitsChanged;  
  17.  

 

  1. boolean set(long index) {   
  2.     if (!get(index)) {   
  3.         data[(int) (index >>> 6)] |= (1L << index);   
  4.         bitCount++;   
  5.         return true;   
  6.     }   
  7.     return false;   
  8. }     
  9.   
  10. boolean get(long index) {   
  11.     return (data[(int) (index >>> 6)] & (1L << index)) != 0;   
  12. }   

02 先get()一下,看看是不是已經(jīng)置為1。 

03 index右移6位就是除以64,說(shuō)明data是long型的數(shù)組,除以64就定位到了bit所在的數(shù)組下標(biāo)。1L左移index位,定位到了bit在long中的位置。 

責(zé)任編輯:龐桂玉 來(lái)源: Python開(kāi)發(fā)者
相關(guān)推薦

2018-05-16 15:46:06

Python網(wǎng)絡(luò)爬蟲(chóng)PhantomJS

2018-05-16 13:50:30

Python網(wǎng)絡(luò)爬蟲(chóng)Scrapy

2018-05-22 15:30:30

Python網(wǎng)絡(luò)爬蟲(chóng)分布式爬蟲(chóng)

2018-05-14 15:27:06

Python網(wǎng)絡(luò)爬蟲(chóng)爬蟲(chóng)架構(gòu)

2018-05-14 16:34:08

Python網(wǎng)絡(luò)爬蟲(chóng)Scrapy

2018-05-14 14:02:41

Python爬蟲(chóng)網(wǎng)易云音樂(lè)

2020-07-10 08:24:18

Python開(kāi)發(fā)工具

2023-03-27 08:28:57

spring代碼,starter

2021-01-30 10:37:18

ScrapyGerapy網(wǎng)絡(luò)爬蟲(chóng)

2011-01-10 14:41:26

2011-05-03 15:59:00

黑盒打印機(jī)

2025-05-07 00:31:30

2021-07-14 09:00:00

JavaFX開(kāi)發(fā)應(yīng)用

2011-02-22 13:46:27

微軟SQL.NET

2021-02-26 11:54:38

MyBatis 插件接口

2021-12-28 08:38:26

Linux 中斷喚醒系統(tǒng)Linux 系統(tǒng)

2021-11-09 09:01:36

Python網(wǎng)絡(luò)爬蟲(chóng)Python基礎(chǔ)

2021-04-01 09:02:38

Python小說(shuō)下載網(wǎng)絡(luò)爬蟲(chóng)

2009-12-24 13:52:57

網(wǎng)絡(luò)接入控制解決方案

2021-07-09 17:27:58

ButterKnife工具APT
點(diǎn)贊
收藏

51CTO技術(shù)棧公眾號(hào)