前言
在以前的文章中,我們學(xué)習(xí)了通過playwright+python+requests可以實現(xiàn)繞過瀏覽器鑒權(quán)進行接口請求。
在曾經(jīng)的一次數(shù)據(jù)爬取的時候,我嘗試去獲取Boss直聘的崗位信息,可是很不巧,boss直聘的反爬機制把我的IP直接封了,妙啊。
在這里給大家推薦一款工具:亮數(shù)據(jù)。
他可以使用真實IP進行代理,從而對目標(biāo)網(wǎng)站數(shù)據(jù)進行獲取。
注冊
注冊地址:點擊注冊免費試用
進入中文版首頁頁面如下:
我們填寫相關(guān)信息進行注冊,注意姓名盡量寫英文,我第一次注冊的時候?qū)懼形暮孟駴]有驗證成功,郵箱填本土的就可以。
這里注冊的時候要注意,我們的密碼要包含英文大小寫+數(shù)字+特殊符號,缺一不可。從這來講,亮數(shù)據(jù)的安全性考慮的不錯。
登錄
注冊成功登錄后界面如下:
功能展示
代理&爬蟲基礎(chǔ)設(shè)施
這個是有什么用呢?這個相當(dāng)于一個遠程瀏覽器,不需要像谷歌瀏覽器、火狐瀏覽器一樣下載到本地,你可以通過遠程連接這個瀏覽器,進行相關(guān)爬蟲操作(這樣即使封IP也封不到自己了,嘿嘿嘿~),后文我會以python-playwright進行示列。
這個瀏覽器的核心優(yōu)勢:
自動繞過驗證碼、封鎖和限制
兼容Puppeteer, Playwright、Selenium
看到第一個了嗎。這個就是我們可以使用的亮數(shù)據(jù)瀏覽器,點進去里面會有相關(guān)信息。
在右側(cè)我們可以獲取demo進行運行,我們分別以python語言-selenium-playwright進行操作。
python-selenium演示
pip3 install selenium
這里的主機名和其他信息改成上文中截圖的,用你們自己注冊的哈。
from selenium.webdriver import Remote, ChromeOptions
from selenium.webdriver.chromium.remote_connection import ChromiumRemoteConnection
SBR_WEBDRIVER = 'https://brd-customer-hl_8dfe8c6c-zone-scraping_browser:y6ebvg0rhg72@brd.superproxy.io:9515'
def main():
print('Connecting to Scraping Browser...')
sbr_connection = ChromiumRemoteConnection(SBR_WEBDRIVER, 'goog', 'chrome')
with Remote(sbr_connection, options=ChromeOptions()) as driver:
print('Connected! Navigating to https://example.com...')
driver.get('https://example.com')
# CAPTCHA handling: If you're expecting a CAPTCHA on the target page, use the following code snippet to check the status of Scraping Browser's automatic CAPTCHA solver
# print('Waiting captcha to solve...')
# solve_res = driver.execute('executeCdpCommand', {
# 'cmd': 'Captcha.waitForSolve',
# 'params': {'detectTimeout': 10000},
# })
# print('Captcha solve status:', solve_res['value']['status'])
print('Navigated! Scraping page content...')
html = driver.page_source
print(html)
if __name__ == '__main__':
main()
python-playwright演示
pip3 install playwright
這里的主機名和其他信息改成上文中截圖的,用你們自己注冊的哈。
import asyncio
from playwright.async_api import async_playwright
SBR_WS_CDP = 'wss://brd-customer-hl_8dfe8c6c-zone-scraping_browser:y6ebvg0rhg72@brd.superproxy.io:9222'
async def run(pw):
print('Connecting to Scraping Browser...')
browser = await pw.chromium.connect_over_cdp(SBR_WS_CDP)
try:
page = await browser.new_page()
print('Connected! Navigating to https://example.com...')
await page.goto('https://example.com')
# CAPTCHA handling: If you're expecting a CAPTCHA on the target page, use the following code snippet to check the status of Scraping Browser's automatic CAPTCHA solver
# client = await page.context.new_cdp_session(page)
# print('Waiting captcha to solve...')
# solve_res = await client.send('Captcha.waitForSolve', {
# 'detectTimeout': 10000,
# })
# print('Captcha solve status:', solve_res['status'])
print('Navigated! Scraping page content...')
html = await page.content()
print(html)
finally:
await browser.close()
async def main():
async with async_playwright() as playwright:
await run(playwright)
if __name__ == '__main__':
asyncio.run(main())
數(shù)據(jù)集展示
在亮數(shù)據(jù)中,我們可以看到很多現(xiàn)成的數(shù)據(jù)集。
進入數(shù)據(jù)商城,在右側(cè)我們可以根據(jù)行業(yè)分類,看到各式各樣的數(shù)據(jù)集,非常非常多
比如我們要查看TikTok的粉絲量大于一百萬的,你可以選擇CSV格式下載或者是JSON格式進行下載,這樣大大方便了自己去爬取。
使用
進入代理&爬蟲基礎(chǔ)設(shè)施,選擇亮數(shù)據(jù)瀏覽器
可以點擊旁邊的免費使用按鈕,顯示演示視頻
這個功能適合以下需求的客戶:
抓取過程需要需要交互(點擊、懸停、在頁面之間導(dǎo)航等)或JavaScript rendering以訪問數(shù)據(jù)的網(wǎng)站。
核心優(yōu)勢:
自動繞過驗證碼、封鎖和限制
兼容Puppeteer, Playwright、Selenium
scraping_browser
你還可以設(shè)置你自己的用戶請求頭和cookie信息
亮數(shù)據(jù)爬蟲IDE
進來之后我們可以看到亮數(shù)據(jù)使用JS編寫的爬取其他網(wǎng)站信息的源碼,并且可以直接在線運行。(這里可以進行借鑒學(xué)習(xí)爬蟲技巧。)
這里我選取了一個tiktok的爬蟲demo,我們可以看到右側(cè)可以直接展示當(dāng)前爬蟲的操作過程。
自定義自己的數(shù)據(jù)集
示列:爬取CSDN的數(shù)據(jù)。
步驟一:選擇按需定制數(shù)據(jù)集
步驟二:新建數(shù)據(jù)集
步驟三:填入目標(biāo)網(wǎng)址
爬取CSDN后端內(nèi)容
https://blog.csdn.net/nav/back-end
https://blog.csdn.net/nav/web
步驟四:進行提交
提交后就會自動抓取
抓取完成后點擊查看
亮數(shù)據(jù)會抓取很多字段,我們需要編輯對應(yīng)的字段,可以根據(jù)自己的需求進行刪減,也可以對字段進行相關(guān)的備注修改。
如果你不想自己自定義,也可以使用AI-defined schema
都編輯好了之后,就滑到最后面點擊接受。
設(shè)置爬取的條數(shù),這里我設(shè)置爬了100
條
點擊提交,之后你可以對爬取到的數(shù)據(jù)進行直接下載。
更多內(nèi)容直接注冊亮數(shù)據(jù)即可免費試用:https://get.brightdata.com/szx9v3lbk0ty文章來源:http://www.zghlxwxcb.cn/news/detail-770178.html
點擊注冊免費試用文章來源地址http://www.zghlxwxcb.cn/news/detail-770178.html
到了這里,關(guān)于輕松爬取網(wǎng)頁數(shù)據(jù):低代碼&零編程技巧的自動化爬蟲神器!的文章就介紹完了。如果您還想了解更多內(nèi)容,請在右上角搜索TOY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!