Hey everyone! I’m working on a personal project and I’m trying to figure out how to show content from another website in my Python web app. The tricky part is that the site I want to display doesn’t allow iframes.
I was thinking of using my remote server as a go-between. It would grab the pages from the other site and then send them to my app. But I’m not sure how to handle all the extra stuff like JavaScript and CSS files.
Does anyone know how I can make this work? What steps do I need to take on both the client and server sides to pull this off? I’m kind of new to this, so any advice would be super helpful!
yo, i’ve done something like this before. u could try using python’s requests library to grab the content server-side. then use beautifulsoup to parse it. for js and css, either proxy em or update the urls. just watch out for CORS probs and make sure ur not breaking any rules with the other site. good luck!
I’ve tackled a similar challenge in one of my projects. Server-side rendering is indeed a good approach here. You’ll want to use a library like requests to fetch the external content on your server. Then, parse the HTML using BeautifulSoup to extract the relevant parts.
For handling JavaScript and CSS, you have a couple of options. You can either proxy these resources through your server or rewrite the URLs to point to the original site. Be cautious with the latter, as it may lead to CORS issues.
Remember to respect the external site’s robots.txt and terms of service. Also, consider caching the fetched content to reduce load on both your server and the external site. This approach requires careful implementation to ensure performance and avoid legal issues.
hey there! have u thought about using a headless browser like Selenium or Puppeteer? they can render the page-server side with all the js and css intact. might be overkill for simple stuff, but could work great for complex pages. what kinda content are u trying to show? just curious!