简体   繁体   English

React Native - 无头浏览器自动化?

[英]React Native - Headless Browser Automation?

I have an app that needs to scrape some data from websites which contain JavaScript.我有一个应用程序需要从包含 JavaScript 的网站上抓取一些数据。 With NodeJS, this is easy with puppeteer or playwright.使用 NodeJS,这对于木偶师或剧作家来说很容易。 With React Native, I can use fetch or axios to request the html of the page, but the Javascript will not be executed.使用 React Native,我可以使用 fetch 或 axios 请求页面的 html,但不会执行 Javascript。

I have learned of a npm package which can allow me to use NodeJS with React Native on Android or iOS ( https://github.com/JaneaSystems/nodejs-mobile-react-native ). I have learned of a npm package which can allow me to use NodeJS with React Native on Android or iOS ( https://github.com/JaneaSystems/nodejs-mobile-react-native ). But since puppeteer or playwright normally automate a desktop version of Chrome, is there any way to achieve similar functionality on mobile devices?但是由于木偶师或剧作家通常会自动执行桌面版 Chrome,有没有办法在移动设备上实现类似的功能?

Apologies if this doesn't help directly, just seeding an idea.抱歉,如果这没有直接帮助,只是播种一个想法。

Why not use a Webview to render the content, then retrieve the web page data?为什么不使用 Webview 渲染内容,然后检索 web 页面数据?

You might be able to affect the Webview's /size/visibility/flex-ccs-style to 'hide' it but I'm not sure exactly how much mileage you can get from each of those techniques.可能能够影响 Webview 的 /size/visibility/flex-ccs-style 以“隐藏”它,但我不确定您可以从每种技术中获得多少里程。

There are articles covering ways of hiding Views (eg containing Webviews) and on-webpage-load events (if you want to get a call back, once the page is rendered).文章涵盖了隐藏视图的方法(例如包含 Webview)和网页加载事件(如果您想在页面呈现后获得回调)。 I'm planing on doing something similar, hopefully, here are some useful articles to help:我正计划做类似的事情,希望这里有一些有用的文章可以提供帮助:

See if any of the above is helpful.看看以上是否有帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM