UPGRADE YOUR SKILLS: Learn advanced Swift and SwiftUI on Hacking with Swift+! >>

How to get full HTML of a page that has a "Load more" button in swift?

Forums > Swift

I am using SwiftSoup to parse the HTML of a website, but there is a "Load more" button at the bottom of the page. I want to get all of the HTML as if I had pressed the load more button until there was no more to load.

Here is the website: https://www.ratemyprofessors.com/professor?tid=2776264 If you scroll down, you can see the black "Load More Ratings" button, and the HTML with more reviews doesn't load unless pressed.

Currently, my code for grabbing the HTML looks like this:

let url = URL(string:"https://www.ratemyprofessors.com/professor?tid=2776264")!

let html = try String(contentsOf: url)

I've used safari and chrome's network tab to try to find the JS command being sent or whatever but there are 10s of things sent per second. I'm new to doing anything with the web so I don't really know anything.

How can I load the rest of the HTML to get it all instead of just the first couple of reviews?

2      

TAKE YOUR SKILLS TO THE NEXT LEVEL If you like Hacking with Swift, you'll love Hacking with Swift+ – it's my premium service where you can learn advanced Swift and SwiftUI, functional programming, algorithms, and more. Plus it comes with stacks of benefits, including monthly live streams, downloadable projects, a 20% discount on all books, and free gifts!

Find out more

Sponsor Hacking with Swift and reach the world's largest Swift community!

Archived topic

This topic has been closed due to inactivity, so you can't reply. Please create a new topic if you need to.

All interactions here are governed by our code of conduct.

 
Unknown user

You are not logged in

Log in or create account
 

Link copied to your pasteboard.