# Sourcing content from a webpage in an organized manner

I've written a script in python to grab different title and address from different pages of a website. Firstly the script will collect all the property links from the landing page and then go one layer deep to collect the title and address. When I run my script, I get the results accordingly.

Should it not be a better approach If I call a single function and the rest of the functions work like a chain to produce the same results? If so, what is the right way to do so?

This is the link to that site

Here is the working script:

import requests
from urllib.parse import urljoin
from bs4 import BeautifulSoup

headers = {"User-Agent":"Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/69.0.3497.100 Safari/537.36"}

def get_token():        #getting csrf_token
r = requests.get(url)
soup = BeautifulSoup(r.text,"lxml")
item = soup.select_one("[name='bhc_csrf_token']")['value']

'bhc_csrf_token': item,
'logout': 1
}

sauce = BeautifulSoup(res.text,"lxml")

soupobj = BeautifulSoup(response.text,"lxml")
name = soupobj.select_one("h2#hp_hotel_name").get_text(strip=True)

Perhaps I misunderstand you. But it looks as though you've already written the functions to call one another: get_info() calls make_post() internally, and make_post() then delegates getting the token to get_token() by calling it internally to itself. So in your final line of code, you should be able to replace the three calls with a single call to get_info().