'Making a browser with flutter
I made a browser with flutter WebView and enabled JavaScript and this is my code for the browser screen.
The main goal for the app is to automate a website (Movies Website) to let the app see the ads of the website but in the background and the app will download the movie by scrapping for the its download link in the HTML page viewed in the WebView of my the flutter app.
BrowserScreen.dart
// ignore_for_file: prefer_const_constructors
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:webview_flutter/webview_flutter.dart';
class BrowserScreen extends StatefulWidget {
const BrowserScreen({Key? key}) : super(key: key);
@override
State<BrowserScreen> createState() => _BrowserScreenState();
}
class _BrowserScreenState extends State<BrowserScreen> {
late WebViewController controller;
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text('My browser'),
),
body: WebView(
onPageStarted: (url) {
if (kDebugMode) {
print(url);
}
},
initialUrl: 'https://rank.egybest.org/',
javascriptMode: JavascriptMode.unrestricted,
onPageFinished: (url) {
// here i will run the javascript code to perform something like scrapping and automation
},
onWebViewCreated: (controller) {
this.controller = controller;
},
),
);
}
}
But the website detects that I am using a WebView and shows a message to use a browser like (Chrome, FireFox ...) How to make my flutter app provides what chrome does for that website to make it open normally into my WebView.
If there is another way to scrap the website without flutter WebView Please Help me.
The WebSite Link is https://yes.egybest.works/
If the link doesn't open with you , Use a VPN in the middle east.
This is A screenshot of my app
Translation of this image (Please use a famous website .Chrome, Firefox...)
Solution 1:[1]
websites can detect WebView by checking userAgent or http-headers..
so you can set user-agent like:
WebView(userAgent: "Mozilla/5.0 (X11; Linux i686; rv:100.0) Gecko/20100101 Firefox/100.0",..)
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 |