Skip to main content

Web Scraping with Mechanical Soup

I'm trying to do a webscraping, but I'm not sure how I should proceed. My code is this:

import mechanicalsoup
browser = mechanicalsoup.StatefulBrowser()
url = "https://www.sas.dk/book/flights/?search=OW_CPH-NYC- 20230703_a1c0i0y0&view=upsell&bookingFlow=points&sortBy=rec&filterBy=all"
browser.open(url)

#Get HTML
print(browser.get_current_page())

the outcome is this:

<!DOCTYPE html>
<html data-cluster="new" data-country="dk" data-lang="da" data-market="dk-da" lang="da-DK">
<head>
<title>Flight Selection | SAS</title>
<base href="/"/>
<meta charset="utf-8"/>
<meta content="yes" name="apple-mobile-web-app-capable"/>
<meta content="minimum-scale=1.0, width=device-width" name="viewport"/>
<meta content="IE=edge,chrome=1" http-equiv="X-UA-Compatible"/>
<link href="/appdata/webclips/apple-touch-icon.png?v=1" rel="apple-touch-icon" sizes="180x180"/>
<link href="/appdata/webclips/favicon-32x32.png?v=1" rel="icon" sizes="32x32" type="image/png"/>
<link href="/appdata/webclips/favicon-16x16.png?v=1" rel="icon" sizes="16x16" type="image/png"/>
<link href="/appdata/webclips/site.webmanifest?v=1" rel="manifest"/>
<link color="#000099" href="/appdata/webclips/safari-pinned-tab.svg?v=1" rel="mask-icon"/>
<s4s-notification></s4s-notification>
<app-upsell></app-upsell>
<script async="" src="https://components.flysas.com/v1/book-ui-upsell/assets/js/book-ui-upsell-widget.js"></script>
<script>!function(e,t){var s=!!navigator.userAgent.match(/lighthouse|page speed|pagespeed|headless|webpagetest|PTST|googlebot|devtools|insights/gi),o=!!t.cookie.match(/(^|;\s?)_cookienew=acknowledged($|;)/gi);function n(){var e,n,a;o||s||(e=t.createElement("s4s-privacy-module"),t.body.insertBefore(e,t.body.children[0]),n=t.createElement("link"),a=t.getElementsByTagName("head")[0],n.href="/v2/cms-s4s-components/s4s-privacy-module/s4s-privacy-module.css",n.rel="stylesheet",n.type="text/css",a.insertAdjacentElement("beforeend",n))}n(),e.addEventListener("loadCookieModal",(function(e){n()}))}(window,document);</script>
<script async="" data-host="components" id="flysas-loader" src="https://components.flysas.com/v2/cms-s4s-elements/s4s-loader-rev.js"></script>      
<script async="" data-host="components" id="flysas-icons" src="https://components.flysas.com/v2/cms-s4s-elements/partials/icons/icons.js"></script> 
<script async="" id="flysas-lazy" src="/v2/cms-www/js/helpers/lazy-src.js"></script>
<script async="" id="flysas-event" src="/v2/cms-www/js/helpers/s4s-event.js"></script>
<script async="" id="flysas-gtm" src="https://components.flysas.com/v2/cms-s4s-elements/partials/analytics/tagmanager.js"></script>
<s4s-product-module market="dk-da"></s4s-product-module>
</body>
</html>

I need to look in the subcode in this section in the outcome "app-upsell></app-upsell", but I don't know how. I need to go through of the element in the table.

Can someone help me, please?



source https://stackoverflow.com/questions/76284747/web-scraping-with-mechanical-soup

Comments

Popular posts from this blog

Prop `className` did not match in next js app

I have written a sample code ( Github Link here ). this is a simple next js app, but giving me error when I refresh the page. This seems to be the common problem and I tried the fix provided in the internet but does not seem to fix my issue. The error is Warning: Prop className did not match. Server: "MuiBox-root MuiBox-root-1" Client: "MuiBox-root MuiBox-root-2". Did changes for _document.js, modified _app.js as mentioned in official website and solutions in stackoverflow. but nothing seems to work. Could someone take a look and help me whats wrong with the code? Via Active questions tagged javascript - Stack Overflow https://ift.tt/2FdjaAW

How to show number of registered users in Laravel based on usertype?

i'm trying to display data from the database in the admin dashboard i used this: <?php use Illuminate\Support\Facades\DB; $users = DB::table('users')->count(); echo $users; ?> and i have successfully get the correct data from the database but what if i want to display a specific data for example in this user table there is "usertype" that specify if the user is normal user or admin i want to user the same code above but to display a specific usertype i tried this: <?php use Illuminate\Support\Facades\DB; $users = DB::table('users')->count()->WHERE usertype =admin; echo $users; ?> but it didn't work, what am i doing wrong? source https://stackoverflow.com/questions/68199726/how-to-show-number-of-registered-users-in-laravel-based-on-usertype

Why is my reports service not connecting?

I am trying to pull some data from a Postgres database using Node.js and node-postures but I can't figure out why my service isn't connecting. my routes/index.js file: const express = require('express'); const router = express.Router(); const ordersCountController = require('../controllers/ordersCountController'); const ordersController = require('../controllers/ordersController'); const weeklyReportsController = require('../controllers/weeklyReportsController'); router.get('/orders_count', ordersCountController); router.get('/orders', ordersController); router.get('/weekly_reports', weeklyReportsController); module.exports = router; My controllers/weeklyReportsController.js file: const weeklyReportsService = require('../services/weeklyReportsService'); const weeklyReportsController = async (req, res) => { try { const data = await weeklyReportsService; res.json({data}) console