主頁 > 企業開發 > 用selenium,beautifulsoup抓取父子關系資料

用selenium,beautifulsoup抓取父子關系資料

2022-03-16 01:44:17 企業開發

我希望你們都做得很好!我正在嘗試抓取此血統串列(https://cov-lineages.org/lineage_list.html),并且血統與父子相關。我必須做的:

  1. 遍歷串列(這個https://cov-lineages.org/lineage_list.html)并單擊每個元素刮取其資料
  2. 然后轉到包含每個譜系的突變表的鏈接(在同一頁面中)并將其廢棄,
  3. 向下滾動到具有該譜系子代的表,回圈遍歷它們,單擊其中的每一個并廢棄其資料,如果每個子代有子代,我們也應該執行相同的程序并廢棄它們。我在這里通過 pdf 檔案中的螢屏截圖進行了解釋,請看一下,看看你是否能想出一個關于如何實作樹或嵌套字典的想法。

uj5u.com熱心網友回復:

你不需要 Selenium 來執行這個任務,requests就可以完成這項作業。

此代碼將獲取串列中的所有行:

import requests
from bs4 import BeautifulSoup

res = requests.get('https://cov-lineages.org/lineage_list.html')
soup = BeautifulSoup(res.text, 'html.parser')

rows = soup.find_all('tr')

for row in rows:
    print(row)

從這里您可以使用row.find_all('td'). 使用檢查CTRL SHIFT I器來識別所需的 html 元素。

uj5u.com熱心網友回復:

資料都在 json 源中,供站點呈現。直接獲取資料就行了,效率更高。這將在很短的時間內獲得您使用 Selenium 抓取的所有資料。這將需要幾秒鐘,而不是幾個小時,通過讓 Selenium 點擊每個單獨的 1907 父鏈接,然后(我什至不知道有多少......但看起來你會讓 Selenium 點擊總共 2181 個左右的鏈接)下的子鏈接。

就將其轉換為該輸出而言,計算邏輯并確定哪些血統是哪些父母的后代,然后從葉節點向上構造它有點棘手。而且我確信有更好的方法來編碼它,但我認為這可以做到:

import requests
import pandas as pd
import re


# Source data
# This will get each individual lineage data into the desired form
_url = 'https://raw.githubusercontent.com/cov-lineages/lineages-website/master/_data/lineage_data.json'
jsonData = requests.get(_url).json()
jsonData = [v for k,v in jsonData.items()]
sourceData = {}

for _each in jsonData:
    _lineage = _each['Lineage']
    _description = _each['Description']
    _most_common_countries = _each['Countries']
    _earliest_date = _each['Earliest date']
    _number_designated = _each['Number designated']
    _number_assigned = _each['Number assigned']
    _children = []

    sourceData[_lineage] = {
            'id':_lineage,
            'description':_description,
            'most_common_countries':_most_common_countries,
            'earliest_date':_earliest_date,
            'number_designated':_number_designated,
            'number_assigned':_number_assigned,
            'children':[]}



# This parses the yml file to work out which child belongs to which parent
_url = 'https://cov-lineages.org/data/lineages.yml'
_response = requests.get(_url).text
_lineages = re.findall('(name: |parent: )(.*)', _response)

parent_children = {}
# Create dictionary of all parent lineages
for _idx, _lineage in enumerate(_lineages):
    if _lineage[0] == 'parent: ' and _lineage[1] != '' and _lineage[1] not in parent_children.keys():
        parent_children[_lineage[-1]] = {'children':[]}
        
    if _lineage[1] == '' and _lineages[_idx-1][1] not in parent_children.keys():
        parent_children[_lineages[_idx-1][1]] = {'children':[]}


# Match parent with appropriate children
for _idx, _lineage in enumerate(_lineages):
    if (_idx 1 == len(_lineages) or (_lineages[_idx][0] == 'name: ' and _lineages[_idx 1][0] == 'name: ')) or (_lineages[_idx 1][-1] == ''):
        continue 

    if _lineages[_idx 1][0] == 'parent: ':
        parent_children[_lineages[_idx 1][-1]]['children'].append(_lineages[_idx][-1])



# Creates a list and dictionary so that I can call out the parent
# given a child by it's key/lineage id
parent_child_relations = []
child_parent_relations = {}
for parent, children in parent_children.items():
    child_list = children['children']
    for child in child_list:
        parent_child_relations.append([parent, child])
        child_parent_relations.update({child:parent})


# Creates the "family tree" of each child to then iterate through
nested_child_parent = {}
for each in child_parent_relations:
    familyOrder = []
    current = each
    belong_to = child_parent_relations[current]
    
    familyOrder.append(belong_to)
    continueLoop = True
    while continueLoop == True:
        current = belong_to
        try:
            belong_to = child_parent_relations[current]
            familyOrder.append(belong_to)
        except:
            continueLoop = False
            #familyOrder.reverse()
            nested_child_parent[each] = familyOrder

# Sorts that list from the "deepest" branches so that I can
# reconstruct from bottom leaf             
sorted_nested_child_parent = {}
for each in nested_child_parent.items():
    length_of_branches = len(each[-1])
    
    if length_of_branches not in sorted_nested_child_parent.keys():
        sorted_nested_child_parent[length_of_branches] = []
    sorted_nested_child_parent[length_of_branches].append(each)

lengthKeys = list(sorted_nested_child_parent.keys())   
lengthKeys.sort() 
lengthKeys.reverse()


# Starts to add the children lineage data into appropriate parent's children list
# in the source data
for x in lengthKeys:
    listToAggregate = sorted_nested_child_parent[x]
    for each in listToAggregate:
        current = each[0]
        
        for parent in each[1]:
            lineageData = sourceData[current]
            if parent not in sourceData.keys():
                sourceData[parent] = {            
                    'id':parent,
                    'description':'NA',
                    'most_common_countries':'NA',
                    'earliest_date':'NA',
                    'number_designated':'NA',
                    'number_assigned':'NA',
                    'children':[]}
                
            
            # if lineageData not already in children, add it
            if not lineageData in sourceData[parent]['children']:
                sourceData[parent]['children'].append(lineageData)
            current = parent
            

# Gets the list of the main/top lineages    
mainNodes = []
parent_list = list(pd.read_html('https://cov-lineages.org/lineage_list.html')[0]['Lineage'])
for each in parent_list:
    try:
        parent = child_parent_relations[each]
        child = each
    except:
        print(f'{each} is not a child.')
        mainNodes.append(each)

# Gets the main/top lineages from the source data
# and puts into the output list
output = []
for each in mainNodes:
    output.append(sourceData[each])

樣本輸出:

[
  {
    "id": "A",
    "description": "Root of the pandemic lies within lineage A. Many sequences originating from China and many global exports; including to South East Asia Japan South Korea Australia the USA and Europe represented in this lineage",
    "most_common_countries": "United States of America 27.0%, United_Arab_Emirates 12.0%, China 9.0%, Germany 8.0%, Canada 5.0%",
    "earliest_date": "2019-12-30",
    "number_designated": 1698,
    "number_assigned": 2317,
    "children": [
      {
        "id": "B",
        "description": "Second major haplotype (and first to be discovered)",
        "most_common_countries": "United States of America 37.0%, United Kingdom 20.0%, China 7.0%, Mexico 6.0%, Germany 3.0%",
        "earliest_date": "2019-12-24",
        "number_designated": 4009,
        "number_assigned": 9162,
        "children": [
          {
            "id": "B.1",
            "description": "A large European lineage the origin of which roughly corresponds to the Northern Italian outbreak early in 2020.",
            "most_common_countries": "United States of America 46.0%, United Kingdom 8.0%, Turkey 8.0%, Canada 4.0%, France 4.0%",
            "earliest_date": "2020-01-03",
            "number_designated": 46252,
            "number_assigned": 95711,
            "children": [
              {
                "id": "B.1.1",
                "description": "European lineage with 3 clear SNPs `28881GA`,`28882GA`,`28883GC`",
                "most_common_countries": "United Kingdom 27.0%, United States of America 14.0%, Japan 7.0%, Russia 5.0%, Turkey 4.0%",
                "earliest_date": "2020-01-08",
                "number_designated": 22834,
                "number_assigned": 49224,
                "children": [
                  {
                    "id": "B.1.1.1",
                    "description": "England",
                    "most_common_countries": "United Kingdom 53.0%, Peru 10.0%, Belgium 4.0%, United States of America 3.0%, Italy 2.0%",
                    "earliest_date": "2020-03-02",
                    "number_designated": 1745,
                    "number_assigned": 2913,
                    "children": [
                      {
                        "id": "C.36",
                        "description": "Alias of B.1.1.1.36, Egypt mainly and other countries",
                        "most_common_countries": "Egypt 33.0%, Germany 11.0%, United Kingdom 10.0%, United States of America 7.0%, Denmark 6.0%",
                        "earliest_date": "2020-03-13",
                        "number_designated": 220,
                        "number_assigned": 1042,
                        "children": [
                          {
                            "id": "C.36.3",
                            "description": "Alias of B.1.1.1.36.3, Europe and USA lineage, from pango-designation issue #80",
                            "most_common_countries": "Germany 18.0%, United States of America 18.0%, Switzerland 9.0%, Italy 8.0%, United Kingdom 7.0%",
                            "earliest_date": "2021-01-04",
                            "number_designated": 493,
                            "number_assigned": 1681,
                            "children": [
                              {
                                "id": "C.36.3.1",
                                "description": "Alias of B.1.1.1.36.3.1, Europe and USA lineage, from pango-designation issue #80",
                                "most_common_countries": "Germany 64.0%, United States of America 18.0%, Belgium 9.0%, Bulgaria 3.0%, Netherlands 3.0%",
                                "earliest_date": "2021-03-29",
                                "number_designated": 54,
                                "number_assigned": 324,
                                "children": []
                              }
                            ]
                          },
                          {
                            "id": "C.36.1",
                            "description": "Alias of B.1.1.1.36.1, Canada",
                            "most_common_countries": "Canada 97.0%, United States of America 2.0%, Burkina_Faso 1.0%, Egypt 1.0%",
                            "earliest_date": "2020-06-24",
                            "number_designated": 21,
                            "number_assigned": 199,
                            "children": []
                          },
                          {
                            "id": "C.36.2",
                            "description": "Alias of B.1.1.1.36.2, Switzerland",
                            "most_common_countries": "Switzerland 80.0%, Norway 7.0%, Germany 3.0%, United States of America 3.0%, Sweden 3.0%",
                            "earliest_date": "2020-10-16",
                            "number_designated": 18,
                            "number_assigned": 30,
                            "children": []
                          }
                        ]
                      },
                      {
                        "id": "C.1",
                        "description": "Alias of B.1.1.1.1, South Africa",
                        "most_common_countries": "South_Africa 91.0%, Zambia 4.0%, United States of America 3.0%, Mozambique 1.0%, Zimbabwe 0.0%",
                        "earliest_date": "2020-01-03",
                        "number_designated": 242,
                        "number_assigned": 351,
                        "children": [
                          {
                            "id": "C.1.1",
                            "description": "Alias of B.1.1.1.1.1, Mozambique",
                            "most_common_countries": "Mozambique 100.0%",
                            "earliest_date": "2020-11-25",
                            "number_designated": 12,
                            "number_assigned": 13,
                            "children": []
                          },
                          {
                            "id": "C.1.2",
                            "description": "Alias of B.1.1.1.1.2, mostly South Africa, from pango-designation issue #139",
                            "most_common_countries": "South_Africa 88.0%, Eswatini 4.0%, Russia 2.0%, United Kingdom 1.0%, Botswana 1.0%",
                            "earliest_date": "2021-04-07",
                            "number_designated": 15,
                            "number_assigned": 281,
                            "children": []
                          }
                        ]
                      },
                      {
                        "id": "C.2",
                        "description": "Alias of B.1.1.1.2, South Africa and some European",
                        "most_common_countries": "South_Africa 44.0%, Zimbabwe 32.0%, Denmark 8.0%, United Kingdom 8.0%, Australia 6.0%",
                        "earliest_date": "2020-06-09",
                        "number_designated": 25,
                        "number_assigned": 50,
                        "children": [
                          {
                            "id": "C.2.1",
                            "description": "Alias of B.1.1.1.2.1, Aruba and Curacao",
                            "most_common_countries": "Aruba 60.0%, United States of America 28.0%, Cura\u00e7ao 9.0%, Netherlands 3.0%, Finland 1.0%",
                            "earliest_date": "2020-12-18",
                            "number_designated": 58,
                            "number_assigned": 150,
                            "children": []
                          }
                        ]
                      }

uj5u.com熱心網友回復:

這是代碼,我正常刮表然后轉到每一頁,我只取血統的名稱,然后轉到爆發網站,刮掉突變。之后,我嘗試用這些構建樹,但我不確定缺少什么。

import json
from selenium.webdriver.support import expected_conditions as EC
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.support.wait import WebDriverWait

driverPath = "C:\Program Files (x86)\chromedriver.exe"
driver = webdriver.Chrome(driverPath)
driver.get("https://cov-lineages.org/lineage_list.html")
# Locate data from the table.
lineages = driver.find_elements(By.XPATH, '//tbody/tr/td[1]/a')
mostCommonCountries = driver.find_elements(By.XPATH, '//tbody/tr/td[2]')
earliestDate = driver.find_elements(By.XPATH, '//tbody/tr/td[3]')
designatedNumbers = driver.find_elements(By.XPATH, '//tbody/tr/td[4]')
assignedNumbers = driver.find_elements(By.XPATH, '//tbody/tr/td[5]')
descriptions = driver.find_elements(By.XPATH, '//tbody/tr/td[6]')

result = []
for i in range(len(lineages)):
    data = {
        'Lineages': lineages[i].text,
        'mostCommonCountries': mostCommonCountries[i].text,
        'earliestDate': earliestDate[i].text,
        'designatedNumbers': designatedNumbers[i].text,
        'assignedNumbers': assignedNumbers[i].text,
        'descriptions': descriptions[i].text
    }
    result.append(data)

    parent_xpath = "//*[@id='pageTitle']"
    outbreak_id = "outbreakLink"
    show_button_xpath = "//*[@id='definition']/div/div[3]/button"
    outbreak_data_xpath = "//*[@id='mutation-table']/div/div/div/table"
    links = [item.get_attribute('href') for item in driver.find_elements(By.XPATH, '//tbody/tr/td[1]/a')]
    for item in links:
        driver.get(item)
        try:
            parent = driver.find_element(By.XPATH, parent_xpath).text
            lineage_string = 'Lineage'
            name = parent.replace(lineage_string, '')
            print(name)

        except Exception as e:
            parent = None
            print(e)
        # Locate View more information at Outbreak.info- href
        outbreak_link = driver.find_element(By.ID, outbreak_id)
        # click on the href
        outbreak_link.click()
        # now we're on the outbreak website
        # View mutation table
        wait = WebDriverWait(driver, 100)
        button_to_show = wait.until(EC.element_to_be_clickable((By.XPATH, show_button_xpath)))
        button_to_show.click()
        outbreak_data = driver.find_element(By.XPATH, outbreak_data_xpath)

    item['parent'] = name
    item['outbreak_data'] = outbreak_data


# # ------- Building the tree

def generate_tree(root_lineage):
    parent_dict = [item for item in result if item.get('Lineages') == root_lineage][
        0]
    parent_dict['children'] = []
    children_names = [item.get('Lineages') for item in result if item.get(
        'parent') == root_lineage]
    for child_name in children_names:
        child_dict = generate_tree(child_name)
        parent_dict['children'].append(child_dict)

    return parent_dict


my_tree = []
root_lineages_names = [item.get('Lineages') for item in result if
                       not item.get('parent')]
for root_lineage_name in root_lineages_names:
    sub_tree = generate_tree(root_lineage_name)
    my_tree.append(sub_tree)

# save my_tree as a .json file
json_format = json.dumps(my_tree)
print(json_format)

轉載請註明出處,本文鏈接:https://www.uj5u.com/qiye/444123.html

標籤:Python 网页抓取 美丽的汤 硒铬驱动程序

上一篇:如何使用SeleniumPython按標題單擊元素

下一篇:Symfony6將物件持久化到資料庫

標籤雲
其他(157675) Python(38076) JavaScript(25376) Java(17977) C(15215) 區塊鏈(8255) C#(7972) AI(7469) 爪哇(7425) MySQL(7132) html(6777) 基礎類(6313) sql(6102) 熊猫(6058) PHP(5869) 数组(5741) R(5409) Linux(5327) 反应(5209) 腳本語言(PerlPython)(5129) 非技術區(4971) Android(4554) 数据框(4311) css(4259) 节点.js(4032) C語言(3288) json(3245) 列表(3129) 扑(3119) C++語言(3117) 安卓(2998) 打字稿(2995) VBA(2789) Java相關(2746) 疑難問題(2699) 细绳(2522) 單片機工控(2479) iOS(2429) ASP.NET(2402) MongoDB(2323) 麻木的(2285) 正则表达式(2254) 字典(2211) 循环(2198) 迅速(2185) 擅长(2169) 镖(2155) 功能(1967) .NET技术(1958) Web開發(1951) python-3.x(1918) HtmlCss(1915) 弹簧靴(1913) C++(1909) xml(1889) PostgreSQL(1872) .NETCore(1853) 谷歌表格(1846) Unity3D(1843) for循环(1842)

熱門瀏覽
  • IEEE1588PTP在數字化變電站時鐘同步方面的應用

    IEEE1588ptp在數字化變電站時鐘同步方面的應用 京準電子科技官微——ahjzsz 一、電力系統時間同步基本概況 隨著對IEC 61850標準研究的不斷深入,國內外學者提出基于IEC61850通信標準體系建設數字化變電站的發展思路。數字化變電站與常規變電站的顯著區別在于程序層傳統的電流/電壓互 ......

    uj5u.com 2020-09-10 03:51:52 more
  • HTTP request smuggling CL.TE

    CL.TE 簡介 前端通過Content-Length處理請求,通過反向代理或者負載均衡將請求轉發到后端,后端Transfer-Encoding優先級較高,以TE處理請求造成安全問題。 檢測 發送如下資料包 POST / HTTP/1.1 Host: ac391f7e1e9af821806e890 ......

    uj5u.com 2020-09-10 03:52:11 more
  • 網路滲透資料大全單——漏洞庫篇

    網路滲透資料大全單——漏洞庫篇漏洞庫 NVD ——美國國家漏洞庫 →http://nvd.nist.gov/。 CERT ——美國國家應急回應中心 →https://www.us-cert.gov/ OSVDB ——開源漏洞庫 →http://osvdb.org Bugtraq ——賽門鐵克 →ht ......

    uj5u.com 2020-09-10 03:52:15 more
  • 京準講述NTP時鐘服務器應用及原理

    京準講述NTP時鐘服務器應用及原理京準講述NTP時鐘服務器應用及原理 安徽京準電子科技官微——ahjzsz 北斗授時原理 授時是指接識訓通過某種方式獲得本地時間與北斗標準時間的鐘差,然后調整本地時鐘使時差控制在一定的精度范圍內。 衛星導航系統通常由三部分組成:導航授時衛星、地面檢測校正維護系統和用戶 ......

    uj5u.com 2020-09-10 03:52:25 more
  • 利用北斗衛星系統設計NTP網路時間服務器

    利用北斗衛星系統設計NTP網路時間服務器 利用北斗衛星系統設計NTP網路時間服務器 安徽京準電子科技官微——ahjzsz 概述 NTP網路時間服務器是一款支持NTP和SNTP網路時間同步協議,高精度、大容量、高品質的高科技時鐘產品。 NTP網路時間服務器設備采用冗余架構設計,高精度時鐘直接來源于北斗 ......

    uj5u.com 2020-09-10 03:52:35 more
  • 詳細解讀電力系統各種對時方式

    詳細解讀電力系統各種對時方式 詳細解讀電力系統各種對時方式 安徽京準電子科技官微——ahjzsz,更多資料請添加VX 衛星同步時鐘是我京準公司開發研制的應用衛星授時時技術的標準時間顯示和發送的裝置,該裝置以M國全球定位系統(GLOBAL POSITIONING SYSTEM,縮寫為GPS)或者我國北 ......

    uj5u.com 2020-09-10 03:52:45 more
  • 如何保證外包團隊接入企業內網安全

    不管企業規模的大小,只要企業想省錢,那么企業的某些服務就一定會采用外包的形式,然而看似美好又經濟的策略,其實也有不好的一面。下面我通過安全的角度來聊聊使用外包團的安全隱患問題。 先看看什么服務會使用外包的,最常見的就是話務/客服這種需要大量重復性、無技術性的服務,或者是一些銷售外包、特殊的職能外包等 ......

    uj5u.com 2020-09-10 03:52:57 more
  • PHP漏洞之【整型數字型SQL注入】

    0x01 什么是SQL注入 SQL是一種注入攻擊,通過前端帶入后端資料庫進行惡意的SQL陳述句查詢。 0x02 SQL整型注入原理 SQL注入一般發生在動態網站URL地址里,當然也會發生在其它地發,如登錄框等等也會存在注入,只要是和資料庫打交道的地方都有可能存在。 如這里http://192.168. ......

    uj5u.com 2020-09-10 03:55:40 more
  • [GXYCTF2019]禁止套娃

    git泄露獲取原始碼 使用GET傳參,引數為exp 經過三層過濾執行 第一層過濾偽協議,第二層過濾帶引數的函式,第三層過濾一些函式 preg_replace('/[a-z,_]+\((?R)?\)/', NULL, $_GET['exp'] (?R)參考當前正則運算式,相當于匹配函式里的引數 因此傳遞 ......

    uj5u.com 2020-09-10 03:56:07 more
  • 等保2.0實施流程

    流程 結論 ......

    uj5u.com 2020-09-10 03:56:16 more
最新发布
  • 使用Django Rest framework搭建Blog

    在前面的Blog例子中我們使用的是GraphQL, 雖然GraphQL的使用處于上升趨勢,但是Rest API還是使用的更廣泛一些. 所以還是決定回到傳統的rest api framework上來, Django rest framework的官網上給了一個很好用的QuickStart, 我參考Qu ......

    uj5u.com 2023-04-20 08:17:54 more
  • 記錄-new Date() 我忍你很久了!

    這里給大家分享我在網上總結出來的一些知識,希望對大家有所幫助 大家平時在開發的時候有沒被new Date()折磨過?就是它的諸多怪異的設定讓你每每用的時候,都可能不小心踩坑。造成程式意外出錯,卻一下子找不到問題出處,那叫一個煩透了…… 下面,我就列舉它的“四宗罪”及應用思考 可惡的四宗罪 1. Sa ......

    uj5u.com 2023-04-20 08:17:47 more
  • 使用Vue.js實作文字跑馬燈效果

    實作文字跑馬燈效果,首先用到 substring()截取 和 setInterval計時器 clearInterval()清除計時器 效果如下: 實作代碼如下: <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta ......

    uj5u.com 2023-04-20 08:12:31 more
  • JavaScript 運算子

    JavaScript 運算子/運算子 在 JavaScript 中,有一些運算子可以使代碼更簡潔、易讀和高效。以下是一些常見的運算子: 1、可選鏈運算子(optional chaining operator) ?.是可選鏈運算子(optional chaining operator)。?. 可選鏈操 ......

    uj5u.com 2023-04-20 08:02:25 more
  • CSS—相對單位rem

    一、概述 rem是一個相對長度單位,它的單位長度取決于根標簽html的字體尺寸。rem即root em的意思,中文翻譯為根em。瀏覽器的文本尺寸一般默認為16px,即默認情況下: 1rem = 16px rem布局原理:根據CSS媒體查詢功能,更改根標簽的字體尺寸,實作rem單位隨螢屏尺寸的變化,如 ......

    uj5u.com 2023-04-20 08:02:21 more
  • 我的第一個NPM包:panghu-planebattle-esm(胖虎飛機大戰)使用說明

    好家伙,我的包終于開發完啦 歡迎使用胖虎的飛機大戰包!! 為你的主頁添加色彩 這是一個有趣的網頁小游戲包,使用canvas和js開發 使用ES6模塊化開發 效果圖如下: (覺得圖片太sb的可以自己改) 代碼已開源!! Git: https://gitee.com/tang-and-han-dynas ......

    uj5u.com 2023-04-20 08:01:50 more
  • 如何在 vue3 中使用 jsx/tsx?

    我們都知道,通常情況下我們使用 vue 大多都是用的 SFC(Signle File Component)單檔案組件模式,即一個組件就是一個檔案,但其實 Vue 也是支持使用 JSX 來撰寫組件的。這里不討論 SFC 和 JSX 的好壞,這個仁者見仁智者見智。本篇文章旨在帶領大家快速了解和使用 Vu ......

    uj5u.com 2023-04-20 08:01:37 more
  • 【Vue2.x原始碼系列06】計算屬性computed原理

    本章目標:計算屬性是如何實作的?計算屬性快取原理以及洋蔥模型的應用?在初始化Vue實體時,我們會給每個計算屬性都創建一個對應watcher,我們稱之為計算屬性watcher ......

    uj5u.com 2023-04-20 08:01:31 more
  • http1.1與http2.0

    一、http是什么 通俗來講,http就是計算機通過網路進行通信的規則,是一個基于請求與回應,無狀態的,應用層協議。常用于TCP/IP協議傳輸資料。目前任何終端之間任何一種通信方式都必須按Http協議進行,否則無法連接。tcp(三次握手,四次揮手)。 請求與回應:客戶端請求、服務端回應資料。 無狀態 ......

    uj5u.com 2023-04-20 08:01:10 more
  • http1.1與http2.0

    一、http是什么 通俗來講,http就是計算機通過網路進行通信的規則,是一個基于請求與回應,無狀態的,應用層協議。常用于TCP/IP協議傳輸資料。目前任何終端之間任何一種通信方式都必須按Http協議進行,否則無法連接。tcp(三次握手,四次揮手)。 請求與回應:客戶端請求、服務端回應資料。 無狀態 ......

    uj5u.com 2023-04-20 08:00:32 more