diff --git "a/data/2.python\344\270\255\351\230\266/3.\347\275\221\347\273\234\347\210\254\350\231\253/10.\345\212\250\346\200\201\346\270\262\346\237\223\351\241\265\351\235\242\347\210\254\345\217\226/config.json" "b/data/2.python\344\270\255\351\230\266/3.\347\275\221\347\273\234\347\210\254\350\231\253/10.\345\212\250\346\200\201\346\270\262\346\237\223\351\241\265\351\235\242\347\210\254\345\217\226/config.json" index 6c942eeb66dd6cee4f795d5a38731c1142f71a56..70d1b53207ace32562e8ccb735754ad5df9bdb96 100644 --- "a/data/2.python\344\270\255\351\230\266/3.\347\275\221\347\273\234\347\210\254\350\231\253/10.\345\212\250\346\200\201\346\270\262\346\237\223\351\241\265\351\235\242\347\210\254\345\217\226/config.json" +++ "b/data/2.python\344\270\255\351\230\266/3.\347\275\221\347\273\234\347\210\254\350\231\253/10.\345\212\250\346\200\201\346\270\262\346\237\223\351\241\265\351\235\242\347\210\254\345\217\226/config.json" @@ -1,5 +1,5 @@ { - "export": [], + "export": ["dynamic_page.json"], "keywords": [], "children": [ { diff --git "a/data/2.python\344\270\255\351\230\266/3.\347\275\221\347\273\234\347\210\254\350\231\253/10.\345\212\250\346\200\201\346\270\262\346\237\223\351\241\265\351\235\242\347\210\254\345\217\226/dynamic_page.json" "b/data/2.python\344\270\255\351\230\266/3.\347\275\221\347\273\234\347\210\254\350\231\253/10.\345\212\250\346\200\201\346\270\262\346\237\223\351\241\265\351\235\242\347\210\254\345\217\226/dynamic_page.json" new file mode 100644 index 0000000000000000000000000000000000000000..9426ef9cd9cad2d53cc3574824d471e6fe85ac0a --- /dev/null +++ "b/data/2.python\344\270\255\351\230\266/3.\347\275\221\347\273\234\347\210\254\350\231\253/10.\345\212\250\346\200\201\346\270\262\346\237\223\351\241\265\351\235\242\347\210\254\345\217\226/dynamic_page.json" @@ -0,0 +1,6 @@ +{ + "author": "zxm2015", + "source": "dynamic_page.md", + "depends": [], + "type": "code_options" +} \ No newline at end of file diff --git "a/data/2.python\344\270\255\351\230\266/3.\347\275\221\347\273\234\347\210\254\350\231\253/10.\345\212\250\346\200\201\346\270\262\346\237\223\351\241\265\351\235\242\347\210\254\345\217\226/dynamic_page.md" "b/data/2.python\344\270\255\351\230\266/3.\347\275\221\347\273\234\347\210\254\350\231\253/10.\345\212\250\346\200\201\346\270\262\346\237\223\351\241\265\351\235\242\347\210\254\345\217\226/dynamic_page.md" new file mode 100644 index 0000000000000000000000000000000000000000..a2c871ca0588c7d37e9e88d0aaf267c6de3a3435 --- /dev/null +++ "b/data/2.python\344\270\255\351\230\266/3.\347\275\221\347\273\234\347\210\254\350\231\253/10.\345\212\250\346\200\201\346\270\262\346\237\223\351\241\265\351\235\242\347\210\254\345\217\226/dynamic_page.md" @@ -0,0 +1,56 @@ +# 爬取动态页面 + +现在想爬取一个url为下拉滚动的页面,下列选项可以爬取到下列页面内容的是: + + + +## 答案 + +```python +import time +from selenium import webdriver +from bs4 import BeautifulSoup + +driver = webdriver.Chrome() +driver.get(url); +Thread.sleep(1000); + +page_size = 10 +for i in range(page_size): + time.sleep(2) + js = "var q=document.documentElement.scrollTop=10000" + driver.execute_script(js) + +page = BeautifulSoup(driver.page_source, 'lxml') +print(page.text) +``` + +## 选项 + +### A + +``` +以上均不正确 +``` + +### B + +```python +import requests + +response = requests.get(url=url) +page = BeautifulSoup(response.text, 'lxml') +print(page.text) +``` + +### C + +```python +import urllib.request + +response = urllib.request.urlopen(url) +buff = response.read() +html = buff.decode("utf8") +page = BeautifulSoup(html, 'lxml') +print(page.text) +``` diff --git "a/data/2.python\344\270\255\351\230\266/3.\347\275\221\347\273\234\347\210\254\350\231\253/11.\346\250\241\346\213\237\347\231\273\345\275\225/simulate_login.json" "b/data/2.python\344\270\255\351\230\266/3.\347\275\221\347\273\234\347\210\254\350\231\253/11.\346\250\241\346\213\237\347\231\273\345\275\225/simulate_login.json" index 2ffcdc91663407cf839a76702085ebe0e5247d19..859db924fd5a6d955f00a8a5e45683f4b6ae5e05 100644 --- "a/data/2.python\344\270\255\351\230\266/3.\347\275\221\347\273\234\347\210\254\350\231\253/11.\346\250\241\346\213\237\347\231\273\345\275\225/simulate_login.json" +++ "b/data/2.python\344\270\255\351\230\266/3.\347\275\221\347\273\234\347\210\254\350\231\253/11.\346\250\241\346\213\237\347\231\273\345\275\225/simulate_login.json" @@ -3,4 +3,4 @@ "source": "simulate_login.md", "depends": [], "type": "code_options" - } \ No newline at end of file +} diff --git "a/data/2.python\344\270\255\351\230\266/3.\347\275\221\347\273\234\347\210\254\350\231\253/6.Selenium/selenium.json" "b/data/2.python\344\270\255\351\230\266/3.\347\275\221\347\273\234\347\210\254\350\231\253/6.Selenium/selenium.json" index 318d6af29f8159ce119ae23f219ee780be80ee85..564aec3150863232a1282e3f551da7adc5056a6d 100644 --- "a/data/2.python\344\270\255\351\230\266/3.\347\275\221\347\273\234\347\210\254\350\231\253/6.Selenium/selenium.json" +++ "b/data/2.python\344\270\255\351\230\266/3.\347\275\221\347\273\234\347\210\254\350\231\253/6.Selenium/selenium.json" @@ -3,4 +3,4 @@ "source": "selenium.md", "depends": [], "type": "code_options" - } \ No newline at end of file +} diff --git "a/data/2.python\344\270\255\351\230\266/3.\347\275\221\347\273\234\347\210\254\350\231\253/8.pyspider\346\241\206\346\236\266\347\232\204\344\275\277\347\224\250/pyspider.json" "b/data/2.python\344\270\255\351\230\266/3.\347\275\221\347\273\234\347\210\254\350\231\253/8.pyspider\346\241\206\346\236\266\347\232\204\344\275\277\347\224\250/pyspider.json" index 8192d3aba962c14d02ade1054bb015d811ddd450..3e7130b96af7de55a74cab179c72f6a2e63c55ce 100644 --- "a/data/2.python\344\270\255\351\230\266/3.\347\275\221\347\273\234\347\210\254\350\231\253/8.pyspider\346\241\206\346\236\266\347\232\204\344\275\277\347\224\250/pyspider.json" +++ "b/data/2.python\344\270\255\351\230\266/3.\347\275\221\347\273\234\347\210\254\350\231\253/8.pyspider\346\241\206\346\236\266\347\232\204\344\275\277\347\224\250/pyspider.json" @@ -3,4 +3,4 @@ "source": "pyspider.md", "depends": [], "type": "code_options" - } \ No newline at end of file +} diff --git "a/data/2.python\344\270\255\351\230\266/3.\347\275\221\347\273\234\347\210\254\350\231\253/9.\351\252\214\350\257\201\347\240\201\345\244\204\347\220\206/verification_code.json" "b/data/2.python\344\270\255\351\230\266/3.\347\275\221\347\273\234\347\210\254\350\231\253/9.\351\252\214\350\257\201\347\240\201\345\244\204\347\220\206/verification_code.json" index 5e98e3bcedf702a07fc362e66efb9e69ffde0fd1..9820a530dbe3c248d278ab398265d0dc062ee439 100644 --- "a/data/2.python\344\270\255\351\230\266/3.\347\275\221\347\273\234\347\210\254\350\231\253/9.\351\252\214\350\257\201\347\240\201\345\244\204\347\220\206/verification_code.json" +++ "b/data/2.python\344\270\255\351\230\266/3.\347\275\221\347\273\234\347\210\254\350\231\253/9.\351\252\214\350\257\201\347\240\201\345\244\204\347\220\206/verification_code.json" @@ -3,4 +3,4 @@ "source": "verification_code.md", "depends": [], "type": "code_options" - } \ No newline at end of file +}