简体   繁体   中英

Get meta tags from external URL using Ruby on Rails and Ajax

I'm creating a form which contains the fields "URL", "Title" and "Image". I'd like to update the value of title and image textboxes when user paste a URL in the first field(onkeyup). These values could come from meta tags. How can I do it? Thanks.

You could perform an ajax request to a second endpoint within your app, which sends the url that the user has entered. That endpoint would use the opengraph gem which extracts the metadata and returns it to the page as json data. That data would then be used to populate the other form fields.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM