Bright Data MCP:突破AI数据获取限制的革命性工具

Bright Data MCP:突破AI数据获取限制的革命性工具
image-20250819022217431


文章目录

一、引言 | 传统方案的落后

传统AI应用依赖预训练数据集,在信息快速迭代的环境中捉襟见肘。静态数据库无法反映最新事实,致使AI输出过时甚至错误信息。预训练模型受限于知识截止日期,对新事件一无所知。

如果采用AI应用实时访问网页数据,采用传统爬虫频繁遭遇验证码、IP封锁等反爬措施,导致AI获取网页信息有限且缺乏真实性,使系统在关键决策时刻难以提供可靠支持。这一核心挑战使得AI实时获取动态网页信息成为技术难题,不仅需要突破反爬机制的限制,还需确保获取内容的完整性和准确性,以满足用户对实时信息的迫切需求。我发现了Bright Data MCP可以解决这个问题,在大语言模型(LLM)、人工智能代理和应用程序顺畅访问、搜索、爬取和浏览实时网络数据期间提供强大支持,同时规避封禁。

二、Bright Data MCP

MCP(模型上下文协议)是连接AI与外部世界的桥梁,它允许AI模型与各类工具、数据源建立安全的双向通信。作为中间层,MCP使AI应用能向外部资源请求信息并获取响应,突破了模型的知识局限,让AI能获取实时数据并执行复杂任务。这一标准化协议为AI生态系统的开放协作奠定了基础,显著提升了AI应用的实用价值。
output.gif

Bright Data MCP是一款突破性的模型上下文协议服务器,由网络数据领域的权威团队Bright Data精心打造。作为专为公共网络访问设计的尖端解决方案,它赋予大型语言模型(LLMs)、智能代理和应用程序前所未有的能力——实时访问、智能发现并精准提取网络数据,同时巧妙规避地理限制和复杂的反爬虫机制。

该工具与Claude Desktop、Cursor等多种客户端实现了无缝集成,并提供可选的远程浏览器自动化功能,为用户创造流畅的操作体验。凭借其强大的技术架构和灵活的适应性,Bright Data MCP成为需要实时网络数据支持的各类应用场景的理想之选,为网络爬虫和数据采集任务树立了新标准。比如访问API,支持静态与动态网页等场景。

免费额度:每月 5,000 次请求,前 3 个月免费!

Bright Data MCP(Machine Concurrent Proxy)是一款强大的网络数据采集工具,具有以下显著优势:

核心优势

自动维护代理池:智能管理大规模代理资源,确保高可用性和稳定性自动解锁功能:能够绕过常见的网站防护机制和访问限制JavaScript渲染支持:自动处理动态加载内容,确保完整数据采集多种运行模式:Rapid模式:适合高速、大规模数据采集Pro模式:提供更高级的解锁能力和浏览器仿真

技术特性

URL参数控制:通过简单参数调整工具行为unlocker:启用高级解锁功能browser:控制浏览器仿真行为pro=1:切换至专业模式广泛兼容性:支持Claude、Cursor、各类语言模型等多种客户端集成远程浏览器自动化:提供可选的浏览器自动化功能,增强数据采集能力

三、部署 MCP 服务器

目前MCP 服务器支持远程托管与本地部署两种部署方式,个人是比较推荐远程托管调用MCP服务,本地部署可能比较适合一些高级用户,存在一些环境上的需求。
image-20250819184808803

两种部署方式

  1. 远程(托管)MCP:Bright Data 云端托管,无需自行搭建。远程 MCP 快速入门
  2. 本地(自托管)MCP:您可以在本地或私有云环境中部署。本地 MCP 快速入门

这里我们选取其中一种方式,在Claude Desktop Extension中调用MCP实现网页问答即可。为了减少学习的成本,就可以快速上手调用MCP进行服务,就采用远端托管进行实战演示。同时会提供另外一种本地部署的策略或者思路。

注意为了突出主要内容,关于环境安装或者一些其他问题会在文件末尾提供

3.1 本地自托管MCP服务器(选看)

(1). 先决条件:

  1. Bright Data账号
  2. Bright Data API密钥
  3. Node.js环境(确保最新版本)
如果您更喜欢使用不同的区域名称,可以在配置中使用 WEB_UNLOCKER_ZONE 环境变量来指定它

(2). 基本配置

转到 AI编程引用-> 设置 -> 开发人员 -> 编辑配置 -> config.json 以包含以下内容:

高级配置】:

如果要使用速率限制或自定义区域等高级功能,可以添加更多环境变量:

3.1.1 简单调用API接口

我们可以在Trae软件中,配置下Bright Data MCP提供的JSON配置文件,进行调用。

该API密钥会更新,大家可以换成自己的。
image-20250819180751798
image-20250819181157655

参数:

{"url":"https://www.flightsfrom.com/JFK-LHR"}

响应:

Direct (non-stop) flights from New York to London - schedules - FlightsFrom.com [](/) **New York** JFK Your search did not result in any matches. Please try again. **London** LHR Your search did not result in any matches. Please try again. Your searches did not result in any direct flight matches. Maybe you want to fly with stops instead? ![](/img/flightsfromlogo-invert.png)### Menu * [Home](/) * [Search airport](/) * [Compare prices](/outbound/search?from=JFK&to=LHR&label=menu) * [Accommodation](/book/hotels?label=menu) * [Car rentals](/book/cars?label=menu) * [All destinations from New York (JFK)](/JFK) * [Airports in USA](/usa) * [Airports in the USA](/usa) * [Airports in the UK](/usa) * [Airports in Canada](/usa) * [Top 100 biggest airports](/top100airports) * [Top 100 biggest airlines](/top100airlines) * [News & fun facts](/articles) * * * FlightsFrom.com is a useful website for finding airline routes and flight schedules globally. The idea is being able to explore destination opportunities through non-stop flights from a specific airport. It's a tool to set up your business meeting or weekend holiday based on your timeschedule and your closest airport. * [Read more about the idea behind FlightsFrom.com](/en/about-us) Round trip Round trip One-way 1 adult \- + 1 adults \- + 0 children Economy Economy Business AD [+1 (831) 271-0274](tel:+18312710274): Unpublished Flight Rates **From to** CHECK PRICES * * * AD [+1 (831) 271-0274](tel:+18312710274): Unpublished Flight Rates **From New York to London** # Direct (non-stop) flights from New York to London All flight schedules from **John F Kennedy International , New York , USA** to **Heathrow, United Kingdom**. This route is operated by 5 airlines and the flight time is 7 hours and 36 minutes. The distance is 3461 miles. [Monthly schedule](#ff-tab-0) [Week schedules](#ff-tab-1) [American Airlines](#ff-tab-1) [British Airways](#ff-tab-2) [Delta Air Lines](#ff-tab-3) [Virgin Atlantic](#ff-tab-4) [JetBlue Airways](#ff-tab-5) [Airlines](#direct-airlines) [Aircrafts](#aircrafts) Price search **JFK** John F Kennedy International ![USA](/img/flags2/us.svg) New York , NY , USA **LHR** Heathrow ![United Kingdom](/img/flags2/gb.svg) London, United Kingdom [CHANGE DIRECTION](/LHR-JFK) Flight time **7h 36m** Flight distance **3461mi, 5569km** ![Flights from New York to London route map](https://www.flightsfrom.com/routes/JFK-LHR.png) VIEW LARGER MAP ![New York to London flight map](https://www.flightsfrom.com/routes/JFK-LHR.png) [SHOW ROUTE ON THE MAP EXPLORER](/explorer/JFK?mapview#LHR) CHECK PRICES ![USA](/img/flags2/us.svg) USA [JFK](/JFK) New York , NY ![aircraft image](/img/routes/plane.png) United Kingdom ![United Kingdom](/img/flags2/gb.svg) [LHR](/LHR) London Distance 3461 miles · (5569 km) [CHANGE DIRECTION](/LHR-JFK) Flight time 7 hours and 36 minutes ### Airlines with direct flights from New York (JFK) to London (LHR) * ![American Airlines](/img/airlines/100/AA_100px.png "American Airlines") American Airlines Oneworld S M T W T F S Business available 4 daily flights * ![British Airways](/img/airlines/100/BA_100px.png "British Airways") British Airways Oneworld S M T W T F S Business available 8 daily flights * ![Delta](/img/airlines/100/DL_100px.png "Delta") Delta Air Lines Sky Team S M T W T F S Business available 2 daily flights * ![Virgin Atlantic](/img/airlines/100/VS_100px.png "Virgin Atlantic") Virgin Atlantic Sky Team S M T W T F S Business available 6 daily flights * ![JetBlue](/img/airlines/100/B6_100px.png "JetBlue") JetBlue Airways S M T W T F S Low-cost airline 2 daily flights SELECT DATES & SHOW PRICES JFK LHR Select dates Check prices MONTHLY ![AA](/img/airlines/100/AA_100px.png) WEEKLY ![BA](/img/airlines/100/BA_100px.png) WEEKLY ![DL](/img/airlines/100/DL_100px.png) WEEKLY ![VS](/img/airlines/100/VS_100px.png) WEEKLY ![B6](/img/airlines/100/B6_100px.png) WEEKLY ### New York (JFK) to London (LHR) flight schedule The monthly calendar shows every direct flight departure from John F Kennedy International (JFK) with all airlines. Click on a date to see a list of flights or search for the best prices. ![](/img/airlines/100/AA_100px.png) American Airlines ![](/img/airlines/100/B6_100px.png) JetBlue ![](/img/airlines/100/BA_100px.png) British Airways ![](/img/airlines/100/DL_100px.png) Delta ![](/img/airlines/100/VS_100px.png) Virgin Atlantic [View return flights from LHR to JFK](/LHR-JFK) ### American Airlines flight schedule from New York to London All weekly departures with American Airlines. The week calendar shows every flight departure from New York (JFK) to London (LHR). Click on a blue date to see a list of flights. Week 35 (Aug 25 - Aug 31) * Week 33 (Aug 11 - Aug 17) * Week 34 (Aug 18 - Aug 24) * Week 35 (Aug 25 - Aug 31) * Week 36 (Sep 1 - Sep 7) * Week 37 (Sep 8 - Sep 14) * Week 38 (Sep 15 - Sep 21) * Week 39 (Sep 22 - Sep 28) * Week 40 (Sep 29 - Oct 5) * Week 41 (Oct 6 - Oct 12) * Week 42 (Oct 13 - Oct 19) * Week 43 (Oct 20 - Oct 26) * Week 44 (Oct 27 - Nov 2) * Week 45 (Nov 3 - Nov 9) * Week 46 (Nov 10 - Nov 16) * Week 47 (Nov 17 - Nov 23) * Week 48 (Nov 24 - Nov 30) * Week 49 (Dec 1 - Dec 7) * Week 50 (Dec 8 - Dec 14) * Week 51 (Dec 15 - Dec 21) * Week 52 (Dec 22 - Dec 28) * Week 01 (Dec 29 - Jan 4) * Week 02 (Jan 5 - Jan 11) * Week 03 (Jan 12 - Jan 18) * Week 04 (Jan 19 - Jan 25) * Week 05 (Jan 26 - Feb 1) * Week 06 (Feb 2 - Feb 8) * Week 07 (Feb 9 - Feb 15) * Week 08 (Feb 16 - Feb 22) * Week 09 (Feb 23 - Mar 1) * Week 10 (Mar 2 - Mar 8) * Week 11 (Mar 9 - Mar 15) * Week 12 (Mar 16 - Mar 22) * Week 13 (Mar 23 - Mar 29) * Week 14 (Mar 30 - Apr 5) * Week 15 (Apr 6 - Apr 12) * Week 16 (Apr 13 - Apr 19) * Week 17 (Apr 20 - Apr 26) * Week 18 (Apr 27 - May 3) * Week 19 (May 4 - May 10) * Week 20 (May 11 - May 17) * Week 21 (May 18 - May 24) * Week 22 (May 25 - May 31) * Week 23 (Jun 1 - Jun 7) * Week 24 (Jun 8 - Jun 14) * Week 25 (Jun 15 - Jun 21) * Week 26 (Jun 22 - Jun 28) * Week 27 (Jun 29 - Jul 5) * Week 28 (Jul 6 - Jul 12) * Week 29 (Jul 13 - Jul 19) * Week 30 (Jul 20 - Jul 26) * Week 31 (Jul 27 - Aug 2) * Week 32 (Aug 3 - Aug 9) * Week 33 (Aug 10 - Aug 16) * Week 34 (Aug 17 - Aug 23) * Week 35 (Aug 24 - Aug 30) * Week 36 (Aug 31 - Sep 6) * Week 37 (Sep 7 - Sep 13) * Week 38 (Sep 14 - Sep 20) * Week 39 (Sep 21 - Sep 27) * Week 40 (Sep 28 - Oct 4) Flight Mon Aug 25 Tue Aug 26 Wed Aug 27 Thu Aug 28 Fri Aug 29 Sat Aug 30 Sun Aug 31 AA142 09:45 09:45 09:45 09:45 09:45 09:45 09:45 AA100 18:10 18:10 18:10 18:10 18:10 18:10 18:10 AA106 19:29 19:29 19:29 19:29 19:29 19:29 19:29 AA104 22:55 22:55 22:55 22:55 22:55 22:55 22:55 ### British Airways flight schedule from New York to London All weekly departures with British Airways. The week calendar shows every flight departure from New York (JFK) to London (LHR). Click on a blue date to see a list of flights. Week 35 (Aug 25 - Aug 31) * Week 33 (Aug 11 - Aug 17) * Week 34 (Aug 18 - Aug 24) * Week 35 (Aug 25 - Aug 31) * Week 36 (Sep 1 - Sep 7) * Week 37 (Sep 8 - Sep 14) * Week 38 (Sep 15 - Sep 21) * Week 39 (Sep 22 - Sep 28) * Week 40 (Sep 29 - Oct 5) * Week 41 (Oct 6 - Oct 12) * Week 42 (Oct 13 - Oct 19) * Week 43 (Oct 20 - Oct 26) * Week 44 (Oct 27 - Nov 2) * Week 45 (Nov 3 - Nov 9) * Week 46 (Nov 10 - Nov 16) * Week 47 (Nov 17 - Nov 23) * Week 48 (Nov 24 - Nov 30) * Week 49 (Dec 1 - Dec 7) * Week 50 (Dec 8 - Dec 14) * Week 51 (Dec 15 - Dec 21) * Week 52 (Dec 22 - Dec 28) * Week 01 (Dec 29 - Jan 4) * Week 02 (Jan 5 - Jan 11) * Week 03 (Jan 12 - Jan 18) * Week 04 (Jan 19 - Jan 25) * Week 05 (Jan 26 - Feb 1) * Week 06 (Feb 2 - Feb 8) * Week 07 (Feb 9 - Feb 15) * Week 08 (Feb 16 - Feb 22) * Week 09 (Feb 23 - Mar 1) * Week 10 (Mar 2 - Mar 8) * Week 11 (Mar 9 - Mar 15) * Week 12 (Mar 16 - Mar 22) * Week 13 (Mar 23 - Mar 29) * Week 14 (Mar 30 - Apr 5) * Week 15 (Apr 6 - Apr 12) * Week 16 (Apr 13 - Apr 19) * Week 17 (Apr 20 - Apr 26) * Week 18 (Apr 27 - May 3) * Week 19 (May 4 - May 10) * Week 20 (May 11 - May 17) * Week 21 (May 18 - May 24) * Week 22 (May 25 - May 31) * Week 23 (Jun 1 - Jun 7) * Week 24 (Jun 8 - Jun 14) * Week 25 (Jun 15 - Jun 21) * Week 26 (Jun 22 - Jun 28) * Week 27 (Jun 29 - Jul 5) * Week 28 (Jul 6 - Jul 12) * Week 29 (Jul 13 - Jul 19) * Week 30 (Jul 20 - Jul 26) * Week 31 (Jul 27 - Aug 2) * Week 32 (Aug 3 - Aug 9) * Week 33 (Aug 10 - Aug 16) * Week 34 (Aug 17 - Aug 23) * Week 35 (Aug 24 - Aug 30) * Week 36 (Aug 31 - Sep 6) * Week 37 (Sep 7 - Sep 13) * Week 38 (Sep 14 - Sep 20) * Week 39 (Sep 21 - Sep 27) * Week 40 (Sep 28 - Oct 4) Flight Mon Aug 25 Tue Aug 26 Wed Aug 27 Thu Aug 28 Fri Aug 29 Sat Aug 30 Sun Aug 31 BA178 07:50 07:50 07:50 07:50 07:50 07:50 07:50 BA112 18:30 18:30 18:30 18:30 18:30 18:30 18:30 BA174 18:45 18:45 18:45 18:45 18:45 18:45 18:45 BA176 19:30 19:30 19:30 19:30 19:30 19:30 19:30 BA116 20:05 20:05 20:05 20:05 20:05 20:05 20:05 BA172 20:55 20:55 20:55 20:55 20:55 20:55 20:55 BA114 21:30 21:30 21:30 21:30 21:30 21:30 21:30 BA182 23:10 23:10 23:10 23:10 23:10 23:10 23:10 ### Delta Air Lines flight schedule from New York to London All weekly departures with Delta Air Lines. The week calendar shows every flight departure from New York (JFK) to London (LHR). Click on a blue date to see a list of flights. Week 35 (Aug 25 - Aug 31) * Week 33 (Aug 11 - Aug 17) * Week 34 (Aug 18 - Aug 24) * Week 35 (Aug 25 - Aug 31) * Week 36 (Sep 1 - Sep 7) * Week 37 (Sep 8 - Sep 14) * Week 38 (Sep 15 - Sep 21) * Week 39 (Sep 22 - Sep 28) * Week 40 (Sep 29 - Oct 5) * Week 41 (Oct 6 - Oct 12) * Week 42 (Oct 13 - Oct 19) * Week 43 (Oct 20 - Oct 26) * Week 44 (Oct 27 - Nov 2) * Week 45 (Nov 3 - Nov 9) * Week 46 (Nov 10 - Nov 16) * Week 47 (Nov 17 - Nov 23) * Week 48 (Nov 24 - Nov 30) * Week 49 (Dec 1 - Dec 7) * Week 50 (Dec 8 - Dec 14) * Week 51 (Dec 15 - Dec 21) * Week 52 (Dec 22 - Dec 28) * Week 01 (Dec 29 - Jan 4) * Week 02 (Jan 5 - Jan 11) * Week 03 (Jan 12 - Jan 18) * Week 04 (Jan 19 - Jan 25) * Week 05 (Jan 26 - Feb 1) * Week 06 (Feb 2 - Feb 8) * Week 07 (Feb 9 - Feb 15) * Week 08 (Feb 16 - Feb 22) * Week 09 (Feb 23 - Mar 1) * Week 10 (Mar 2 - Mar 8) * Week 11 (Mar 9 - Mar 15) * Week 12 (Mar 16 - Mar 22) * Week 13 (Mar 23 - Mar 29) * Week 14 (Mar 30 - Apr 5) * Week 15 (Apr 6 - Apr 12) * Week 16 (Apr 13 - Apr 19) * Week 17 (Apr 20 - Apr 26) * Week 18 (Apr 27 - May 3) * Week 19 (May 4 - May 10) * Week 20 (May 11 - May 17) * Week 21 (May 18 - May 24) * Week 22 (May 25 - May 31) * Week 23 (Jun 1 - Jun 7) * Week 24 (Jun 8 - Jun 14) * Week 25 (Jun 15 - Jun 21) * Week 26 (Jun 22 - Jun 28) * Week 27 (Jun 29 - Jul 5) * Week 28 (Jul 6 - Jul 12) * Week 29 (Jul 13 - Jul 19) * Week 30 (Jul 20 - Jul 26) * Week 31 (Jul 27 - Aug 2) * Week 32 (Aug 3 - Aug 9) * Week 33 (Aug 10 - Aug 16) * Week 34 (Aug 17 - Aug 23) * Week 35 (Aug 24 - Aug 30) * Week 36 (Aug 31 - Sep 6) * Week 37 (Sep 7 - Sep 13) * Week 38 (Sep 14 - Sep 20) * Week 39 (Sep 21 - Sep 27) * Week 40 (Sep 28 - Oct 4) Flight Mon Aug 25 Tue Aug 26 Wed Aug 27 Thu Aug 28 Fri Aug 29 Sat Aug 30 Sun Aug 31 DL1 20:30 20:30 20:30 20:29 20:29 20:29 20:29 DL3 22:00 22:30 22:00 22:00 22:00 22:00 22:00 ### Virgin Atlantic flight schedule from New York to London All weekly departures with Virgin Atlantic. The week calendar shows every flight departure from New York (JFK) to London (LHR). Click on a blue date to see a list of flights. Week 35 (Aug 25 - Aug 31) * Week 33 (Aug 11 - Aug 17) * Week 34 (Aug 18 - Aug 24) * Week 35 (Aug 25 - Aug 31) * Week 36 (Sep 1 - Sep 7) * Week 37 (Sep 8 - Sep 14) * Week 38 (Sep 15 - Sep 21) * Week 39 (Sep 22 - Sep 28) * Week 40 (Sep 29 - Oct 5) * Week 41 (Oct 6 - Oct 12) * Week 42 (Oct 13 - Oct 19) * Week 43 (Oct 20 - Oct 26) * Week 44 (Oct 27 - Nov 2) * Week 45 (Nov 3 - Nov 9) * Week 46 (Nov 10 - Nov 16) * Week 47 (Nov 17 - Nov 23) * Week 48 (Nov 24 - Nov 30) * Week 49 (Dec 1 - Dec 7) * Week 50 (Dec 8 - Dec 14) * Week 51 (Dec 15 - Dec 21) * Week 52 (Dec 22 - Dec 28) * Week 01 (Dec 29 - Jan 4) * Week 02 (Jan 5 - Jan 11) * Week 03 (Jan 12 - Jan 18) * Week 04 (Jan 19 - Jan 25) * Week 05 (Jan 26 - Feb 1) * Week 06 (Feb 2 - Feb 8) * Week 07 (Feb 9 - Feb 15) * Week 08 (Feb 16 - Feb 22) * Week 09 (Feb 23 - Mar 1) * Week 10 (Mar 2 - Mar 8) * Week 11 (Mar 9 - Mar 15) * Week 12 (Mar 16 - Mar 22) * Week 13 (Mar 23 - Mar 29) * Week 14 (Mar 30 - Apr 5) * Week 15 (Apr 6 - Apr 12) * Week 16 (Apr 13 - Apr 19) * Week 17 (Apr 20 - Apr 26) * Week 18 (Apr 27 - May 3) * Week 19 (May 4 - May 10) * Week 20 (May 11 - May 17) * Week 21 (May 18 - May 24) * Week 22 (May 25 - May 31) * Week 23 (Jun 1 - Jun 7) * Week 24 (Jun 8 - Jun 14) * Week 25 (Jun 15 - Jun 21) * Week 26 (Jun 22 - Jun 28) * Week 27 (Jun 29 - Jul 5) * Week 28 (Jul 6 - Jul 12) * Week 29 (Jul 13 - Jul 19) * Week 30 (Jul 20 - Jul 26) * Week 31 (Jul 27 - Aug 2) * Week 32 (Aug 3 - Aug 9) * Week 33 (Aug 10 - Aug 16) * Week 34 (Aug 17 - Aug 23) * Week 35 (Aug 24 - Aug 30) * Week 36 (Aug 31 - Sep 6) * Week 37 (Sep 7 - Sep 13) * Week 38 (Sep 14 - Sep 20) * Week 39 (Sep 21 - Sep 27) * Week 40 (Sep 28 - Oct 4) Flight Mon Aug 25 Tue Aug 26 Wed Aug 27 Thu Aug 28 Fri Aug 29 Sat Aug 30 Sun Aug 31 VS26 08:10 08:10 08:10 08:10 08:10 08:10 08:10 VS4 18:00 18:00 18:00 18:00 18:00 18:00 18:00 VS10 19:00 19:00 19:00 19:00 19:00 19:00 19:00 VS46 21:00 21:00 21:00 21:00 21:00 21:00 21:00 VS154 21:30 21:30 21:30 21:30 21:30 21:30 21:30 VS138 23:25 23:25 23:25 23:25 23:25 23:25 23:25 ### JetBlue Airways flight schedule from New York to London All weekly departures with JetBlue Airways. The week calendar shows every flight departure from New York (JFK) to London (LHR). Click on a blue date to see a list of flights. Week 35 (Aug 25 - Aug 31) * Week 33 (Aug 11 - Aug 17) * Week 34 (Aug 18 - Aug 24) * Week 35 (Aug 25 - Aug 31) * Week 36 (Sep 1 - Sep 7) * Week 37 (Sep 8 - Sep 14) * Week 38 (Sep 15 - Sep 21) * Week 39 (Sep 22 - Sep 28) * Week 40 (Sep 29 - Oct 5) * Week 41 (Oct 6 - Oct 12) * Week 42 (Oct 13 - Oct 19) * Week 43 (Oct 20 - Oct 26) * Week 44 (Oct 27 - Nov 2) * Week 45 (Nov 3 - Nov 9) * Week 46 (Nov 10 - Nov 16) * Week 47 (Nov 17 - Nov 23) * Week 48 (Nov 24 - Nov 30) * Week 49 (Dec 1 - Dec 7) * Week 50 (Dec 8 - Dec 14) * Week 51 (Dec 15 - Dec 21) * Week 52 (Dec 22 - Dec 28) * Week 01 (Dec 29 - Jan 4) * Week 02 (Jan 5 - Jan 11) * Week 03 (Jan 12 - Jan 18) * Week 04 (Jan 19 - Jan 25) * Week 05 (Jan 26 - Feb 1) * Week 06 (Feb 2 - Feb 8) * Week 07 (Feb 9 - Feb 15) * Week 08 (Feb 16 - Feb 22) * Week 09 (Feb 23 - Mar 1) * Week 10 (Mar 2 - Mar 8) * Week 11 (Mar 9 - Mar 15) * Week 12 (Mar 16 - Mar 22) * Week 13 (Mar 23 - Mar 29) * Week 14 (Mar 30 - Apr 5) * Week 15 (Apr 6 - Apr 12) * Week 16 (Apr 13 - Apr 19) * Week 17 (Apr 20 - Apr 26) * Week 18 (Apr 27 - May 3) * Week 19 (May 4 - May 10) * Week 20 (May 11 - May 17) * Week 21 (May 18 - May 24) * Week 22 (May 25 - May 31) * Week 23 (Jun 1 - Jun 7) * Week 24 (Jun 8 - Jun 14) * Week 25 (Jun 15 - Jun 21) * Week 26 (Jun 22 - Jun 28) * Week 27 (Jun 29 - Jul 5) * Week 28 (Jul 6 - Jul 12) * Week 29 (Jul 13 - Jul 19) * Week 30 (Jul 20 - Jul 26) * Week 31 (Jul 27 - Aug 2) * Week 32 (Aug 3 - Aug 9) * Week 33 (Aug 10 - Aug 16) * Week 34 (Aug 17 - Aug 23) * Week 35 (Aug 24 - Aug 30) * Week 36 (Aug 31 - Sep 6) * Week 37 (Sep 7 - Sep 13) * Week 38 (Sep 14 - Sep 20) * Week 39 (Sep 21 - Sep 27) * Week 40 (Sep 28 - Oct 4) Flight Mon Aug 25 Tue Aug 26 Wed Aug 27 Thu Aug 28 Fri Aug 29 Sat Aug 30 Sun Aug 31 B61107 08:45 08:45 08:45 08:45 08:45 08:45 08:45 B67 20:59 20:59 20:59 20:59 20:59 21:00 20:59 Flight time **6h 45m - 7h 36m** Earliest flight **07:50** Last flight **23:25** Distance **3461 miles (5569 km)** Cheapest month **October** Airlines **5 ([Show](#direct-airlines))** Flights per week **147** Departing Terminal (JFK) **Terminal 4, 5 or 8** Arriving Terminal (LHR) **Terminal 2, 3 or 5** America/New York (UTC-4) Europe/London (UTC+1) **LHR +5 hours ahead** ### ![GB](/img/flags2/gb.svg) Arriving at Heathrow (LHR) Heathrow (LHR) is the largest airport in United Kingdom and is based in London. You can fly to 217 destinations with 78 airlines in scheduled passenger traffic. [Show all flights from LHR](/LHR) Best prices on rental cars in London Compare prices and book now with free cancellation. [SEARCH FOR RENTAL CARS](/outbound/search?alt=cars&alt-location=London,United Kingdom&page=JFK-LHR) Hotel deals in London with free cancellation [HOTEL PRICES](/outbound/search?alt=hotels&alt-location=London,United Kingdom&page=JFK-LHR) Top 10 things to do in London Find out what other travelers are looking for in London. [SHOW ACTIVITIES](/r/go/eyJpdiI6IlBtenBrUDNNWStXUHRcL3ZVeTY2MG13PT0iLCJ2YWx1ZSI6IjJQK3dFaWVQTko5Z0RhS2VHU2YzZnRKQXRGVkpreWJaV2ZwU0hZREk5XC9VZm5hK040N3krY2hZVG5rZktrTWxjbHNcL2liVVRcL0hkWTJOWkdZMlZUV1QwWTlvMm9TckJkbkxqd1Rjd29NQndUMnlWNVVzZEdnT2w1UTR2dTZQOUVlWTBWNVBiXC9oa08wT0FINDRjRDBmMFRZbzh6TVk4dzR6U0JBSnVJSm4xZXc9IiwibWFjIjoiOGI5OTM3OTI0ZmJhYTJhMjA0NDFiZTI2ZGIwMGMxYzhjZDU4YzM1MTQyMDIzNThmZjhjZjlkMmI2YjA2ZTAxZSJ9) ### ![US](/img/flags2/us.svg) Departing from John F Kennedy (JFK) , New York John F Kennedy International (JFK) is a large airport based in New York, USA. You can fly to 197 destinations with 72 airlines in scheduled passenger traffic. [Show all flights from JFK](/JFK) ### Airlines with alternative airports from New York to London The airlines below are departing from or arriving to other airports in the same city or very close. ![Air India](/img/airlines/100/AI_100px.png "Air India") Air India Star Alliance Newark Liberty International Heathrow Duration 6 hours and 55 minutes ![British Airways](/img/airlines/100/BA_100px.png "British Airways") British Airways Oneworld Newark Liberty International Heathrow Duration 7 hours and 05 minutes ![United](/img/airlines/100/UA_100px.png "United") United Star Alliance Newark Liberty International Heathrow Duration 7 hours and 30 minutes ![Virgin Atlantic](/img/airlines/100/VS_100px.png "Virgin Atlantic") Virgin Atlantic Sky Team Newark Liberty International Heathrow Duration 7 hours and 10 minutes [Show detailed flight schedule from EWR to LHR](/EWR-LHR) ![Primera Air Scandinavia](/img/airlines/100/PF_100px.png "Primera Air Scandinavia") Primera Air Scandinavia Newark Liberty International Stansted Duration 7 hours and 10 minutes [Show detailed flight schedule from EWR to STN](/EWR-STN) ![British Airways](/img/airlines/100/BA_100px.png "British Airways") British Airways Oneworld John F Kennedy International City Duration 8 hours and 25 minutes [Show detailed flight schedule from JFK to LCY](/JFK-LCY) ![British Airways](/img/airlines/100/BA_100px.png "British Airways") British Airways Oneworld John F Kennedy International Gatwick Duration 7 hours and 05 minutes ![Norwegian Air Shuttle](/img/airlines/100/DY_100px.png "Norwegian Air Shuttle") Norwegian Air Shuttle John F Kennedy International Gatwick Duration 6 hours and 31 minutes ![Norwegian Air UK](/img/airlines/100/DI_100px.png "Norwegian Air UK") Norwegian Air UK John F Kennedy International Gatwick Duration 7 hours and 50 minutes ![Virgin Atlantic](/img/airlines/100/VS_100px.png "Virgin Atlantic") Virgin Atlantic Sky Team John F Kennedy International Gatwick Duration 7 hours and 20 minutes ![JetBlue](/img/airlines/100/B6_100px.png "JetBlue") JetBlue John F Kennedy International Gatwick Duration 7 hours and 25 minutes ![Norse](/img/airlines/100/N0_100px.png "Norse") Norse John F Kennedy International Gatwick Duration 7 hours and 15 minutes ![Delta](/img/airlines/100/DL_100px.png "Delta") Delta Sky Team John F Kennedy International Gatwick Duration 7 hours and 25 minutes ![Norse Atlantic](/img/airlines/100/Z0_100px.png "Norse Atlantic") Norse Atlantic John F Kennedy International Gatwick Duration 7 hours and 05 minutes [Show detailed flight schedule from JFK to LGW](/JFK-LGW) ### New York - London flight price statistics $590 Approximate The numbers are avarage prices found based on user searches for direct flights between John F Kennedy International and Heathrow. Its calculated from the cheapest prices found per month for a round-trip with 1 adult and can vary depending on the amount of data we have for this particular route. **$544** Jan **$544** Feb **$546** Mar **$547** Apr **$1818** May **$645** Jun **$539** Jul **$553** Aug **$566** Sep **$526** Oct **$574** Nov **$574** Dec Approximate prices for one round-trip flight from **New York (JFK)** to **London (LHR)**. Graph is not to scale. CLICK HERE FOR EXACT PRICES ### Type of aircraft(s) on this route Below is a list of aircraft types we have within our database with flights on this route. You can also see the aircrafts **seat capacity** together with classes. ![](/img/airlines/100/AA_100px.png) Boeing 777-200 / 200ER American Airlines ![Boeing 777-200 / 200ER illustration](https://images.flightsfrom.com/aircrafts/777-200_300_withgear.png) ![Boeing 777-200 / 200ER illustration](https://images.flightsfrom.com/aircrafts/777-200_300_withgear.png) 273 seats (24 business class, 24 premium economy) ![](/img/airlines/100/AA_100px.png) Boeing 777-300ER American Airlines ![Boeing 777-300ER illustration](https://images.flightsfrom.com/aircrafts/777-300_300_withgear.png) ![Boeing 777-300ER illustration](https://images.flightsfrom.com/aircrafts/777-300_300_withgear.png) 304 seats (8 first class, 28 business class, 28 premium economy) ![](/img/airlines/100/BA_100px.png) Boeing 777 British Airways ![Boeing 777 illustration](https://images.flightsfrom.com/aircrafts/777-200_300_withgear.png) ![Boeing 777 illustration](https://images.flightsfrom.com/aircrafts/777-200_300_withgear.png) 267 seats (4 first class, 42 business class, 42 premium economy) ![](/img/airlines/100/BA_100px.png) Boeing 787-10 British Airways ![Boeing 787-10 illustration](https://images.flightsfrom.com/aircrafts/787-10_300_withgear.png) ![Boeing 787-10 illustration](https://images.flightsfrom.com/aircrafts/787-10_300_withgear.png) 256 seats (8 first class, 35 business class, 35 premium economy) ![](/img/airlines/100/BA_100px.png) Boeing 777-300ER British Airways ![Boeing 777-300ER illustration](https://images.flightsfrom.com/aircrafts/777-300_300_withgear.png) ![Boeing 777-300ER illustration](https://images.flightsfrom.com/aircrafts/777-300_300_withgear.png) 256 seats (8 first class, 40 business class, 40 premium economy) ![](/img/airlines/100/DL_100px.png) Boeing 767-400 Passenger Delta Air Lines ![Boeing 767-400 Passenger illustration](https://images.flightsfrom.com/aircrafts/767-400_GE_300_withgear.png) ![Boeing 767-400 Passenger illustration](https://images.flightsfrom.com/aircrafts/767-400_GE_300_withgear.png) 238 seats (20 business class, 20 premium economy) ![](/img/airlines/100/DL_100px.png) Airbus A330-900neo Delta Air Lines ![Airbus A330-900neo illustration](https://images.flightsfrom.com/aircrafts/A330-900_NEO_300_withgear.png) ![Airbus A330-900neo illustration](https://images.flightsfrom.com/aircrafts/A330-900_NEO_300_withgear.png) 281 seats (28 business class, 28 premium economy) ![](/img/airlines/100/VS_100px.png) Boeing 787-9 Virgin Atlantic ![Boeing 787-9 illustration](https://images.flightsfrom.com/aircrafts/787-9_300_withgear.png) ![Boeing 787-9 illustration](https://images.flightsfrom.com/aircrafts/787-9_300_withgear.png) 258 seats (35 business class, 35 premium economy) ![](/img/airlines/100/VS_100px.png) Airbus A330-900neo Virgin Atlantic ![Airbus A330-900neo illustration](https://images.flightsfrom.com/aircrafts/A330-900_NEO_300_withgear.png) ![Airbus A330-900neo illustration](https://images.flightsfrom.com/aircrafts/A330-900_NEO_300_withgear.png) 262 seats (46 business class, 46 premium economy) ![](/img/airlines/100/VS_100px.png) Airbus A350-1000 Virgin Atlantic ![Airbus A350-1000 illustration](https://images.flightsfrom.com/aircrafts/A350-900_300_withgear.png) ![Airbus A350-1000 illustration](https://images.flightsfrom.com/aircrafts/A350-900_300_withgear.png) 360 seats (56 business class, 56 premium economy) ![](/img/airlines/100/B6_100px.png) Airbus A321neo JetBlue Airways ![Airbus A321neo illustration](https://images.flightsfrom.com/aircrafts/A321_NEO_CFM_LEAP_300_withgear.png) ![Airbus A321neo illustration](https://images.flightsfrom.com/aircrafts/A321_NEO_CFM_LEAP_300_withgear.png) 167 seats ROUTE EXPLORING ### John F Kennedy International - all destinations With FlightsFrom.com’s brilliant search features you can explore all non-stop flights from a specific airport. Simply select your preferred airport to get an overview of every single non-stop flight offered. Click on one of the routes to get information about which airline’s operate the route, when the next scheduled flight is or to filter your search even more. [EXPLORE ALL DESTINATIONS](/JFK) ![New York flight map](https://www.flightsfrom.com/routes/JFK.png) ### Select your flight details Round trip 1 adult Economy Round trip One way Adults \- 1 + Children \- 0 + Infants \- 0 + Economy Business You may have missed to select a date. Please check the calendar. If you dont know your date, use on the button "I dont know my dates" AD [+1 (831) 271-0274](tel:+18312710274): Unpublished Flight Rates From **New York to London** I HAVE NO DATES CHECK PRICES Check accommodation with our partner AD [+1 (831) 271-0274](tel:+18312710274): Unpublished Flight Rates From **New York to London** ### Frequently asked questions FAQ * How long does a flight from New York (JFK) to London (LHR) take? This long-haul flight from New York (JFK) to London (LHR) takes about 7 hours and 5 minutes. * How many flights per day are there on this route? There are 22 direct flights every day. * What are the flight numbers on the route New York to London? The flight numbers are AA100, AA104, AA106, AA142, B67, B61107, BA112, BA114 together with 17 additional flights. * Which airports will I be using when flying from New York to London? From New York you fly out from John F Kennedy International (JFK) and you'll be landing at Gatwick (LGW), Heathrow (LHR). * What aircraft types are flying on this route? American Airlines, British Airways, Delta, Virgin Atlantic, and JetBlue all flyes the Boeing 787 Dreamliner on this route. * How many airlines fly non-stop from New York (JFK) to London (LHR)? Five airlines. American Airlines, British Airways, Delta, Virgin Atlantic and JetBlue have non-stop flights to London. * What terminals does the aircrafts depart from and on what terminals do they arrive? Flights are arriving at terminal 3 or 2in London (LHR). All flights to London are departing from terminal 8 or 5 at New York (JFK). [VIEW IN MAP EXPLORER](/explorer/JFK?mapview#LHR) ![Flights from New York to London route map](https://www.flightsfrom.com/routes/JFK-LHR.png)##### Non-stop flights from JFK to LHR3461 miles (5569 km) · 7 hours and 36 minutes CHECK PRICES New York (JFK) updates Subscribe to our newsletter and be the first to know about the latest news and flight route updates. Your email address Join forfree You may opt-out at any time![](https://www.flightsfrom.com/img/flightsfromlogo.png?v=1.0.2)#### Popular routes from New York#### ![American Airlines](https://www.flightsfrom.com/img/airlines/100/AA_100px.png) American Airlines routes[ New York (JFK) - Los Angeles (LAX)![US](/img/flags2/us.svg)](/JFK-LAX)[ New York (JFK) - Miami (MIA)![US](/img/flags2/us.svg)](/JFK-MIA)[ New York (JFK) - Charlotte (CLT)![US](/img/flags2/us.svg)](/JFK-CLT)[ New York (JFK) - Boston (BOS)![US](/img/flags2/us.svg)](/JFK-BOS)[ New York (JFK) - San Francisco (SFO)![US](/img/flags2/us.svg)](/JFK-SFO) _For more destinations from New York with American Airlines (AA), check out the [American Airlines route map](/AA) ._ #### ![Delta Air Lines](https://www.flightsfrom.com/img/airlines/100/DL_100px.png) Delta Air Lines routes[ New York (JFK) - Los Angeles (LAX)![US](/img/flags2/us.svg)](/JFK-LAX)[ New York (JFK) - Atlanta (ATL)![US](/img/flags2/us.svg)](/JFK-ATL)[ New York (JFK) - San Francisco (SFO)![US](/img/flags2/us.svg)](/JFK-SFO)[ New York (JFK) - Orlando (MCO)![US](/img/flags2/us.svg)](/JFK-MCO)[ New York (JFK) - Boston (BOS)![US](/img/flags2/us.svg)](/JFK-BOS) _For more destinations from New York with Delta Air Lines (DL), check out the [Delta Air Lines route map](/DL) ._ #### ![JetBlue Airways](https://www.flightsfrom.com/img/airlines/100/B6_100px.png) JetBlue Airways routes[ New York (JFK) - Los Angeles (LAX)![US](/img/flags2/us.svg)](/JFK-LAX)[ New York (JFK) - Orlando (MCO)![US](/img/flags2/us.svg)](/JFK-MCO)[ New York (JFK) - San Juan (SJU)![PR](/img/flags2/pr.svg)](/JFK-SJU)[ New York (JFK) - Santiago (STI)![DO](/img/flags2/do.svg)](/JFK-STI)[ New York (JFK) - Fort Lauderdale (FLL)![US](/img/flags2/us.svg)](/JFK-FLL) _For more destinations from New York with JetBlue Airways (B6), check out the [JetBlue Airways route map](/B6) ._ * [USA](/usa) * [New York (JFK)](/JFK) * London (LHR) AD [+1 (831)271-0274](tel:+18312710274): Unpublished Flight Rates From **New York to London** ### What is FlightsFrom? _FlightsFrom.com is a useful website for finding airline routes and flight schedules globally. The idea is being able to explore destination opportunities through non-stop flights from a specific airport. It's a tool to set up your business meeting or weekend holiday based on your timeschedule and your closest airport._ _Part of its appeal is that it just makes trips easier to plan; you see the departure times of every non-stop flight in a list._ _\- MSN.com_ _I always wondered where you could fly direct from a particular airport (Burbank, I’m looking at you) and those answers can be tough to find. Not anymore!_ _\- Rich on tech_ _Many mainstream sites don’t list low-cost carriers or link transoceanic flights to regionally based carriers that can provide less expensive options. For that, you need a bigger tool kit… (Hint: search by destination airport at FlightsFrom.com)_ _\- The New York Times_ _Many low-cost carriers airlines prevent their flights from showing up on some of these (read Vayama or Google Flights) third-party travel websites. If you want a chance to view all local departures, try using FlightsFrom.com_ _\- Lifehacker_ * * * ### Enjoying our website? Try our newsletter. Wish to receive airport and airline updates? Enter your email below! Subscribe ### Social Media Don't want to miss anything new? Follow us![](https://www.facebook.com/1041114809395901)[](https://www.instagram.com/flightsfrom/)[Select airport](/)[Airport map](/map)[Fun facts](/articles)[Privacy policy](https://www.flightsfrom.com/en/privacy-policy)[About FlightsFrom.com](https://www.flightsfrom.com/en/about-us)[![](https://www.flightsfrom.com/img/flightsfromlogo-invert.png)](https://www.flightsfrom.com) Copyright 20

结果

image-20250819181313458

3.2 远程调用MCP API

(1). 先决条件

  1. Bright Data账号
  2. Bright Data API密钥

首先有Bright Data账号并且获得Bright Data API密钥。如果没有亮数据账号,现在注册,每月免费接收 5000 个请求。

获得Bright Data API密钥请保存起来,是不会显示第二次的。
image-20250824181358455
image-20250824181419365

(2). 选择链接方式

Bright Data MCP提供两种高效连接方式,满足不同场景需求:

  • SSE实时数据流https://mcp.brightdata.com/sse?token=YOUR_API_TOKEN( 适用于需要持续接收服务器推送数据的实时应用场景)
  • HTTP标准请求https://mcp.brightdata.com/mcp?token=YOUR_API_TOKEN(支持流式传输,适合常规数据获取和处理任务)
安全提示:在实际部署中,请将链接中的YOUR_API_TOKEN替换为您的Bright Data授权密钥,确保API访问安全。

MCP server 提供丰富的工具提供调用。比如,等会我们需要实战演示的实时Goolge搜索。

image-20250819131943800
image-20250819181722121

四、Python调用MCP API实时抓取 Google搜索结果

4.1 必看信息

我认为它值得一条"二级标题",我在进行实战过程中遇到的问题和获得知识。如果我说的有问题,可以在评论区交流下,谢谢

Bright Data的MCP服务设计理念是让用户通过特定的客户端工具或环境来使用它们的服务,而不是让用户直接通过编程方式(如REST API调用)来访问和控制MCP服务。

MCP的token主要用于客户端配置,而不是用于直接API调用。所以,当你尝试通过JSON配置文件直接配置MCP,可能会失败。

image-20250819184730894

等等,你说的也不对呀!那为什么HTTP方式可以调用API呢?

对的,通过HTTP方式成功连接搭配MCP服务时,本质也是在调用MCP的API。这里的区别可能在于使用方式和访问级别:

【直接HTTP代理连接】:这是使用MCP作为代理服务器的基本功能当您配置HTTP代理连接时,您实际上是在使用MCP的"数据通道"功能这种方式通常是被允许的,因为这是MCP的核心服务功能

【配置和管理API】:这是用来配置、管理和控制MCP服务本身的API包括创建新的代理配置、修改现有设置、查询使用统计等这部分功能可能被限制只能通过官方工具或特定环境访问

所以,当我说"不是设计用于直接API调用"时,我指的主要是第二类API(配置和管理API),而不是基本的代理连接功能。

通过HTTP成功连接,是使用MCP的基本代理功能,当尝试JSON配置文件来管理或配置MCP服务时遇到的问题,可能时这些管理功能被限制了

这种区分在代理服务中很常见:允许用户通过标准协议使用代理服务,但限制用户直接访问管理和配置API。

【Bright Data MCP服务通常需要通过以下方式访问】:支持MCP协议的IDE环境mcp-remote工具Bright Data提供的官方客户端

4.2 搭建Python脚本

📁 文件结构概览

核心文件包括:mcp_client_fixed.py、interactive_client.py、requirements.txt、README.md**(Token换成你自己的API密钥,我肯定要更新的API的)**
python-mcp-client/ ├── mcp_client_fixed.py # ✅ 修复版核心客户端(推荐使用) ├── mcp_client.py # 原始版核心客户端(有重复内容问题) ├── interactive_client.py # 交互式命令行界面 ├── test_client.py # 测试脚本 ├── requirements.txt # Python依赖文件 └── README.md # 使用说明文档

4.2.1 mcp_client_fixed.py 核心客户端类

image-20250819190047335

主要功能:

🔑 API认证 - 通过URL参数传递Bright Data token📡 HTTP通信 - 处理与Bright Data MCP服务器的通信🔄 会话管理 - 维护会话ID和状态📊 数据解析 - 解析Server-Sent Events格式的响应🔍 搜索功能 - 支持Google/Bing/Yandex搜索

核心类和方法:

MCPClient 类 - 主要客户端类_send_request() - 发送HTTP请求并显示详细API调用信息_parse_sse_data() - 解析Server-Sent Events格式数据connect() - 建立连接并创建会话initialize() - 初始化MCP协议search() - 执行搜索查询scrape() - 抓取网页内容

源码

import requests import json import time from typing import Dict, Any, Optional classMCPClient:"""Python版本的MCP客户端,用于调用Bright Data的MCP服务"""def__init__(self, token:str):""" 初始化MCP客户端 Args: token: Bright Data的API token """ self.token = token self.base_url =f"https://mcp.brightdata.com/mcp?token={token}" self.session_id =None self.message_id =1 self.session = requests.Session()# 设置默认请求头 self.session.headers.update({'Content-Type':'application/json','Accept':'application/json, text/event-stream','User-Agent':'Python-MCP-Client/1.0'})def_parse_sse_data(self, sse_text:str)-> Dict[str, Any]:""" 解析Server-Sent Events格式的数据 Args: sse_text: SSE格式的文本 Returns: 解析后的JSON数据 """try:# 查找data:行 lines = sse_text.split('\n')for line in lines:if line.startswith('data: '): json_str = line[6:]# 移除'data: '前缀# 确保正确的UTF-8编码ifisinstance(json_str,bytes): json_str = json_str.decode('utf-8') data = json.loads(json_str)# 修复搜索结果中的编码问题if'result'in data and'content'in data['result']:for item in data['result']['content']:ifisinstance(item,dict)and'text'in item:# 尝试修复编码问题 text = item['text']ifisinstance(text,str):try:# 尝试重新编码 item['text']= text.encode('latin1').decode('utf-8')except(UnicodeDecodeError, UnicodeEncodeError):# 如果编码修复失败,保持原样passreturn data return{}except(json.JSONDecodeError, Exception)as e:print(f"SSE解析失败: {e}")return{}def_send_request(self, method:str='POST', data: Optional[Dict]=None)-> Dict[str, Any]:""" 发送HTTP请求到MCP端点 Args: method: HTTP方法 (GET, POST等) data: 请求数据 Returns: 响应数据字典 """try:# 打印API调用详情print("\n"+"="*60)print("📡 API 调用详情")print("="*60)print(f"🔗 URL: {self.base_url}")print(f"📋 方法: {method}")# 显示请求头 headers_to_show =dict(self.session.headers)if self.session_id: headers_to_show['mcp-session-id']= self.session_id headers_to_show['X-Session-ID']= self.session_id print(f"📤 请求头:")for key, value in headers_to_show.items():if'token'in key.lower():print(f" {key}: {value[:20]}...{value[-10:]}")# 隐藏部分tokenelse:print(f" {key}: {value}")# 显示请求体if data:print(f"📦 请求体 (JSON):")print(json.dumps(data, indent=2, ensure_ascii=False))else:print(f"📦 请求体: 无")# 如果有会话ID,添加到请求头if self.session_id: self.session.headers['mcp-session-id']= self.session_id self.session.headers['X-Session-ID']= self.session_id # 发送请求if method.upper()=='GET': response = self.session.get(self.base_url)else: response = self.session.post(self.base_url, json=data)# 显示响应详情print(f"\n📥 响应详情:")print(f" 状态码: {response.status_code}")print(f" 响应头:")for key, value in response.headers.items():print(f" {key}: {value}")# 提取会话IDif'mcp-session-id'in response.headers: self.session_id = response.headers['mcp-session-id']print(f" ✅ 会话ID已更新: {self.session_id}")# 显示原始响应内容print(f"\n📄 原始响应内容:")print(f" 长度: {len(response.text)} 字符")print(f" 前200字符: {response.text[:200]}...")# 解析响应if response.text:# 检查是否是Server-Sent Events格式if'text/event-stream'in response.headers.get('content-type',''): parsed_data = self._parse_sse_data(response.text)print(f"\n🔍 解析后的JSON数据:")print(json.dumps(parsed_data, indent=2, ensure_ascii=False)) result ={'status': response.status_code,'data': parsed_data,'headers':dict(response.headers)}else:try: json_data = response.json()print(f"\n🔍 解析后的JSON数据:")print(json.dumps(json_data, indent=2, ensure_ascii=False)) result ={'status': response.status_code,'data': json_data,'headers':dict(response.headers)}except json.JSONDecodeError: result ={'status': response.status_code,'data': response.text,'headers':dict(response.headers)}else: result ={'status': response.status_code,'data':None,'headers':dict(response.headers)}print("="*60)return result except requests.RequestException as e:print(f"❌ 请求失败: {e}")return{'status':0,'data':None,'error':str(e)}defconnect(self)->bool:""" 建立连接并创建会话 - 修复版本 Returns: 连接是否成功 """print("正在连接到Bright Data MCP服务...")# 尝试GET请求创建会话 result = self._send_request('GET')print(f"连接结果: HTTP {result['status']}")print(f"响应内容: {result.get('data','None')}")# 如果返回400且提示需要sessionId,直接跳过连接检查,尝试初始化if result['status']==400and result.get('data')=='No sessionId':print("⚠️ 服务器要求sessionId,跳过连接检查,直接尝试初始化...")returnTrueelif result['status']==200:print("✅ 连接成功!")returnTrueelse:print(f"⚠️ 连接状态异常,但继续尝试: {result.get('data','未知错误')}")returnTrue# 继续尝试,可能服务器有特殊处理definitialize(self)-> Dict[str, Any]:""" 初始化MCP协议连接 Returns: 初始化结果 """ init_message ={"jsonrpc":"2.0","id": self.message_id,"method":"initialize","params":{"protocolVersion":"2024-11-05","capabilities":{"roots":{"listChanged":True},"sampling":{}},"clientInfo":{"name":"Python MCP Client","version":"1.0.0"}}} self.message_id +=1print("正在初始化MCP协议...") result = self._send_request('POST', init_message)print(f"初始化结果: HTTP {result['status']}")if result['status']==200and result['data']andisinstance(result['data'],dict)andnot result['data'].get('error'):# 发送initialized通知 notify_message ={"jsonrpc":"2.0","method":"notifications/initialized"} self._send_request('POST', notify_message)print("✅ MCP协议初始化成功!")else:print(f"⚠️ 初始化响应: {result}")return result deflist_tools(self)-> Dict[str, Any]:""" 获取可用工具列表 Returns: 工具列表 """ message ={"jsonrpc":"2.0","id": self.message_id,"method":"tools/list","params":{}} self.message_id +=1print("正在获取工具列表...") result = self._send_request('POST', message)if result['status']==200and result['data']: tools = result['data'].get('result',{}).get('tools',[])print(f"✅ 发现 {len(tools)} 个可用工具:")for tool in tools:print(f" - {tool.get('name','未知')}: {tool.get('description','无描述')}")else:print(f"⚠️ 工具列表响应: {result}")return result defsearch(self, query:str, engine:str="google")-> Dict[str, Any]:""" 执行搜索 Args: query: 搜索关键词 engine: 搜索引擎 (google, bing, yandex) Returns: 搜索结果 """ message ={"jsonrpc":"2.0","id": self.message_id,"method":"tools/call","params":{"name":"search_engine","arguments":{"query": query,"engine": engine }}} self.message_id +=1print(f"🔍 正在搜索: {query} (使用 {engine})") result = self._send_request('POST', message)if result['status']==200and result['data']: search_results = result['data'].get('result',{}).get('content',[])if search_results:print(f"✅ 找到 {len(search_results)} 个搜索结果\n")# 解析搜索结果for i, item inenumerate(search_results[:5],1):ifisinstance(item,dict): text = item.get('text','')# 解析Markdown格式的搜索结果 lines = text.split('\n') title ="" url ="" description =""# 提取标题、URL和描述for line in lines: line = line.strip()ifnot line:continue# 查找标题(通常是第一行或包含#的行)ifnot title and(line.startswith('#')orlen(line)<100): title = line.replace('#','').strip()# 查找URL(包含http的行)elif'http'in line andnot url:# 提取URLimport re url_match = re.search(r'https?://[^\s\)]+', line)if url_match: url = url_match.group()# 查找描述(较长的文本行)eliflen(line)>50andnot line.startswith('http')andnot description: description = line[:200]+"..."iflen(line)>200else line # 显示格式化的搜索结果print(f"🔍 结果 {i}:")if title:print(f" 📌 标题: {title}")if url:print(f" 🔗 链接: {url}")if description:print(f" 📝 描述: {description}")print("-"*60)else:print(f"📄 结果 {i}: {str(item)[:100]}...")else:print("❌ 未找到搜索结果")else:print(f"⚠️ 搜索响应: {result}")return result defscrape(self, url:str)-> Dict[str, Any]:""" 抓取网页内容 Args: url: 要抓取的网址 Returns: 抓取结果 """ message ={"jsonrpc":"2.0","id": self.message_id,"method":"tools/call","params":{"name":"scrape_as_markdown","arguments":{"url": url }}} self.message_id +=1print(f"🌐 正在抓取网页: {url}") result = self._send_request('POST', message)if result['status']==200and result['data']: content = result['data'].get('result',{}).get('content',[])if content: text_content =''.join([item.get('text','')for item in content ifisinstance(item,dict)])print(f"✅ 抓取成功,内容长度: {len(text_content)} 字符")print(f"预览: {text_content[:200]}...")else:print("❌ 抓取失败或内容为空")else:print(f"⚠️ 抓取响应: {result}")return result # 使用示例if __name__ =="__main__":# 使用你的Bright Data token TOKEN ="57d1a452149d90e8e10399969cedd1c55871600e0c12ed12ef870b448f9a8c06"# 创建客户端 client = MCPClient(TOKEN)print("=== Python MCP客户端测试 (修复版) ===\n")# 1. 连接if client.connect():# 2. 初始化 init_result = client.initialize()# 3. 列出工具 tools_result = client.list_tools()# 4. 执行搜索print("\n--- 搜索测试 ---") search_result = client.search("Python编程教程")print("\n=== 测试完成 ===")else:print("连接失败,无法继续测试")

4.2.2 interactive_client.py 交互式命令行界面

image-20250819190515228

主要功能:

💬 命令行交互 - 提供用户友好的命令行界面🔍 搜索命令 - search <关键词> [引擎]🌐 抓取命令 - scrape <网址>ℹ️ 帮助系统 - 显示可用命令和使用示例

使用方式python interactive_client.py

源码

#!/usr/bin/env python3""" 交互式Python MCP客户端 支持命令行交互使用 """from mcp_client_fixed import MCPClient import sys defprint_help():"""打印帮助信息"""print(""" === Python MCP客户端交互模式 === 可用命令: search <关键词> - 搜索 (默认使用Google) search <关键词> <引擎> - 指定搜索引擎 (google/bing/yandex) scrape <网址> - 抓取网页内容 tools - 列出可用工具 help - 显示此帮助 quit/exit - 退出程序 示例: search Python教程 search 人工智能 bing scrape https://www.example.com """)defmain():# 使用你的Bright Data token TOKEN ="57d1a452149d90e8e10399969cedd1c55871600e0c12ed12ef870b448f9a8c06"print("🚀 启动Python MCP客户端...") client = MCPClient(TOKEN)# 连接和初始化ifnot client.connect():print("❌ 连接失败,程序退出")return client.initialize()print("✅ 客户端已就绪!") print_help()# 交互循环whileTrue:try: user_input =input("\n>>> ").strip()ifnot user_input:continue parts = user_input.split() command = parts[0].lower()if command in['quit','exit']:print("👋 再见!")breakelif command =='help': print_help()elif command =='tools': client.list_tools()elif command =='search':iflen(parts)<2:print("❌ 请提供搜索关键词: search <关键词> [引擎]")continue query =' '.join(parts[1:-1])iflen(parts)>2else' '.join(parts[1:]) engine = parts[-1]iflen(parts)>2and parts[-1]in['google','bing','yandex']else'google'iflen(parts)>2and parts[-1]in['google','bing','yandex']: query =' '.join(parts[1:-1])else: query =' '.join(parts[1:]) engine ='google' result = client.search(query, engine)# 显示详细结果if result['status']==200and result['data']: search_results = result['data'].get('result',{}).get('content',[])if search_results:print(f"\n📋 搜索结果 ({len(search_results)} 条):")for i, item inenumerate(search_results[:5],1):ifisinstance(item,dict): text = item.get('text','') lines = text.split('\n') title = lines[0]if lines else text[:100]print(f"\n{i}. {title}")iflen(lines)>1:print(f" {lines[1][:150]}...")elif command =='scrape':iflen(parts)<2:print("❌ 请提供网址: scrape <网址>")continue url = parts[1]ifnot url.startswith(('http://','https://')): url ='https://'+ url result = client.scrape(url)# 显示抓取结果if result['status']==200and result['data']: content = result['data'].get('result',{}).get('content',[])if content: text_content =''.join([item.get('text','')for item in content ifisinstance(item,dict)])print(f"\n📄 抓取结果 (共 {len(text_content)} 字符):")print("="*50)print(text_content[:1000])# 显示前1000字符iflen(text_content)>1000:print(f"\n... (还有 {len(text_content)-1000} 字符)")print("="*50)else:print(f"❌ 未知命令: {command}")print("输入 'help' 查看可用命令")except KeyboardInterrupt:print("\n\n👋 程序被中断,再见!")breakexcept Exception as e:print(f"❌ 发生错误: {e}")if __name__ =="__main__": main()

4.2.3 requirements.txt Python依赖文件

在这里插入图片描述
requests>=2.25.0 

4.2.4 READEM.md 使用文档(补充流程)

# Python MCP客户端 这是一个Python版本的MCP (Model Context Protocol) 客户端,用于调用Bright Data的搜索和网页抓取服务。 ## 📁 文件结构 ``` python-mcp-client/ ├── mcp_client.py # 核心MCP客户端类 ├── interactive_client.py # 交互式命令行客户端 ├── requirements.txt # Python依赖 └── README.md # 说明文档```## 🚀 快速开始### 1. 安装依赖```bash pip install-r requirements.txt ```### 2. 交互式使用```bash python interactive_client.py ```### 3. 编程使用```python from mcp_client import MCPClient # 创建客户端 client = MCPClient("你的token")# 连接和初始化 client.connect() client.initialize()# 搜索 result = client.search("Python教程")# 网页抓取 result = client.scrape("https://www.example.com")```## 🔧 主要功能### MCPClient类方法 - `connect()` - 建立连接 - `initialize()` - 初始化MCP协议 - `list_tools()` - 获取可用工具 - `search(query, engine)` - 执行搜索 - `scrape(url)` - 抓取网页 ### 交互式命令 - `search <关键词>` - 搜索 - `search <关键词><引擎>` - 指定搜索引擎 - `scrape <网址>` - 抓取网页 - `tools` - 列出工具 - `help` - 帮助 - `quit` - 退出 ## 🌐 支持的搜索引擎 - Google (默认) - Bing - Yandex ## 📝 使用示例```python # 搜索示例 client.search("人工智能", "google") client.search("机器学习", "bing")# 抓取示例 client.scrape("https://www.python.org") client.scrape("https://github.com")```## 🔑 Token配置 在代码中修改TOKEN变量为你的Bright Data token: ```python TOKEN ="你的Bright Data token"

4.3 HTTP方式调用MCP API

首先大家要知道,Bright Data MCP提供了两个工具

  • 搜索功能 - 支持Google/Bing/Yandex
  • 网页抓取 - 任意网页转Markdown
# Token使用 self.base_url = f"https://mcp.brightdata.com/mcp?token={token}"# HTTP请求 response = self.session.post(self.base_url, json=data)# 搜索调用 client.search("Python教程", "google")# 抓取调用  client.scrape("https://www.example.com")

咱们的工作流程

初始化MCPClient 创建实例,传入token连接connect() 建立连接,获取会话ID初始化协议initialize() 初始化MCP协议功能调用search()scrape() 调用相应功能结果处理 → 解析和显示返回结果

使用方式

cd python-mcp-client python interactive_client.py 
image-20250819191351272
image-20250819191457932

请求体(JSON)

image-20250819191540436

响应结果

可以将text内容,丢给AI完成资料整理。我们前面两篇都是一样的做法。
image-20250819191628872
image-20250819191806779

通过验证,连接是可以正常访问的,内容应该没有问题的。不过,推荐大家直接拿着JSON配置文件直接调用API得了,Bright Data MCP功能是十分厉害的,然后搭配n8n Web Scraper Integration专门用于网页数据抓取,可以躺着挣大米。

五、总结和分析

Bright Data MCP不仅是一款技术产品,更代表着数据获取领域的革命性飞跃。作为Bright Data团队智慧的结晶,这一模型上下文协议服务器突破了传统网络数据采集的限制,为人工智能时代的信息获取开辟了全新道路。

尽管市场上存在多种MCP服务,Bright Data MCP凭借其独特优势脱颖而出:它能实时获取网络数据,巧妙绕过地理限制,有效突破网站反爬虫机制,同时支持浏览器自动化和系统无缝集成,确保数据的安全性与可靠性。

使用建议与限制说明

前 3 个月免费额度为每月 5,000 次请求,适合开发测试与轻量级应用超出额度或使用高级功能(如 mcp_browser)将产生费用多用户团队共享免费额度

小二诚挚你尝试使用Bright Data MCP,前 3 个月免费额度为每月 5,000 次请求。同时也推荐大家,使用亮数据其他产品。

亮数据注册连接https://get.brightdata.com/d_mcpserver

Read more

飞书/钉钉/QQ 机器人一站式搞定!OpenClaw Docker 部署教程

飞书/钉钉/QQ 机器人一站式搞定!OpenClaw Docker 部署教程

一、概述 OpenClaw-Docker-CN-IM(OpenClaw 中国IM平台整合Docker版本)是一款容器化应用,旨在提供集成中国主流IM平台的AI机器人网关解决方案。该镜像预装并配置了飞书、钉钉、QQ机器人、企业微信等插件,支持通过环境变量灵活配置,实现快速部署与数据持久化。 同时集成了OpenCode AI代码助手、Playwright浏览器自动化工具及中文TTS语音合成功能,适用于需要构建多平台IM机器人的开发者与科研用户。 本指南将详细介绍其Docker部署流程,包括环境准备、镜像拉取、容器配置、功能测试及生产环境优化建议,帮助用户快速实现服务部署与应用。 二、项目简介与核心特性 2.1 项目简介 OpenClaw 中国 IM 插件整合版 Docker 镜像,预装并配置了飞书、钉钉、QQ机器人、企业微信等主流中国 IM 平台插件,让您可以快速部署一个支持多个中国 IM 平台的 AI 机器人网关。 官方项目地址: https://github.com/justlovemaki/

6层高速PCB设计,立创-逻辑派FPGA-G1开发板,万字笔记。基于立创EDA高速PCB,FPGA,GW2A-LV18PG256C8/17、GD32F303CBT6学习笔记

6层高速PCB设计,立创-逻辑派FPGA-G1开发板,万字笔记。基于立创EDA高速PCB,FPGA,GW2A-LV18PG256C8/17、GD32F303CBT6学习笔记

个人声明:本文章为个人学习PCB六层板设计的学习记录。官方资料请参考嘉立创的相关教程。 我用的是嘉立创EDA的专业版。最后我会放上立创开源广场的连接,大家可以去看一下,跟着官方学习一下,官方非常权威 开源广场的地址我放在文章中,因为需要一个DXF文件,需要导入到EDA 并且六层以下都可以免费打板,对我帮助非常大,尤其是像我这种刚入门的新手来说,给予了很多试错机会,毕竟每个月可以免费打两次。而且立创EDA还是免费的,打开网页就能画板子,相当方便快捷。 一.笔记前资料准备 立创·逻辑派FPGA-G1是一款面向学习和开发的国产FPGA开发板,它的一大特点是采用了FPGA与ARM Cortex-M内核相结合的异构架构,并提供了非常完善的开源资料。 主控:GW2A-LV18PG256C8/17、GD32F303CBT6 FPGA逻辑单元:20KHz。 ARM主频:120MHz。 DDR3内存:2Gbit FPGA端存储:FLASH16M/64M/128M ARM端存储:TF卡2GB/4GB/16GB/32GB FPGA端8P接口支持:Gowin程序下载、GAO在线逻辑仿真

CentOS环境下libwebkit2gtk-4.1-0安装配置手把手教程

手把手教你解决 CentOS 下 libwebkit2gtk-4.1-0 安装难题 你有没有遇到过这样的场景?在 CentOS 上部署一个基于 GTK 的桌面应用,刚运行就报错: error while loading shared libraries: libwebkit2gtk-4.1.so.0: cannot open shared object file: No such file or directory 别急,这不是你的代码问题,而是系统里缺了关键的 Web 渲染引擎库 —— libwebkit2gtk-4.1-0 。 这玩意儿听着冷门,但其实大有来头。它是 GNOME 桌面生态中许多应用程序(比如帮助手册、配置面板、文档浏览器)背后默默工作的“网页内核”。可偏偏在企业级稳定的

Qwen-Image-2512-Pixel-Art-LoRA效果实测:不同分辨率(512/768/1024/1280)对像素密度的影响

Qwen-Image-2512-Pixel-Art-LoRA效果实测:不同分辨率(512/768/1024/1280)对像素密度的影响 1. 引言:像素艺术的魅力与分辨率之谜 像素艺术,这种由一个个小方块构成的独特视觉语言,承载着无数人的童年记忆和复古情怀。从早期的8位机游戏到如今独立游戏的复兴,像素风格始终散发着独特的魅力。然而,当我们用AI来生成像素艺术时,一个看似简单却至关重要的问题浮出水面:分辨率到底如何影响最终的像素密度和艺术效果? 今天,我们就来深入实测Qwen-Image-2512-Pixel-Art-LoRA模型,看看在不同分辨率设置下,生成的像素艺术究竟会发生怎样的变化。这个基于通义万相Qwen-Image-2512大模型的微调版本,专门为像素艺术而生,由社区开发者prithivMLmods训练并开源。它通过LoRA技术,在强大的基座模型上精准注入了像素艺术的灵魂。 很多人可能会想,分辨率不就是图片大小吗?调高调低有什么好研究的?但事实是,在像素艺术这个特殊领域,分辨率的选择直接决定了作品的“像素感”强弱、细节丰富程度,甚至影响整体的艺术风格。选择512×5