I would like to get text and images from the URL posted by the user.
(It's a function that allows you to preview the url destination when you paste url on the Twitter post screen.)
Also, I don't know if I should implement text and image acquisition on iOS or on a server site such as Rails.
Web Displayed in WebView
Unable to retrieve as string imageview.
2) Parse the HTML of the URL destination and obtain the text url
=>
There are countless ways to write tags, so it's hard to get them.
URLObtain url information of RSS from URL destination and parse XML.
=>
1. Get url from RSS (for example, RSS RSS 2.0 Atom)
Parse 2.xmel.
I am wondering if the above method of の can be realized, but I can only get text and images from でも only the URL with RSS information defined.
Twitter and other services also look at the function of retrieving text and images from URLs, but how do you implement them?
I'd like some advice.
swift ruby-on-rails objective-c
Indicates how to run on the server side.
You can specify the images that Twitter retrieves as meta information.
<meta name="twitter:card" content="summary"/>
<meta name="twitter:title" content="Share Title"/>
<meta name="twitter:description" content="Description of page to share"/>
<meta name="twitter: image" content="https://asset.example.com/images/0h13mQN1VzeOAHNFRFinsA.jpg"/>
Twitter tweets are also the first img tag found in the body tag without the above meta information
You may have obtained it with rules such as .
In that case, you can do it with a gem called Nokogiri
.
html=Nokogiri::HTML(open('http://www.nokogiri.org/tutorials/installing_nokogiri.html'))
first_image=html.css('img').first
image_url=first_image.attributes['src'].try(:value) if first_image
If iOS (swift?) also has a library that can be scraped by URL, you may not need to implement it on the server side.
© 2024 OneMinuteCode. All rights reserved.