I am displaying the tweets from a public list but when a tweet has an image it is not displaying the image nor the link of the image but ... and sometimes even the text of the tweet is truncated with ....
How can I make the full tweet text display even if the image is not?
I need the full text for each tweet in the list.
Doing an API call :
$client.get(“https://api.twitter.com/1.1/lists/statuses.json?owner_screen_name=USERNAME&slug=LISTNAME&tweet_mode=extended”)
Related
hello am new to firebase
i just want to fetch data from firebase and display in django(in table)
db look like:
enter image description here
code in view.py look like:
enter image description here
code in html look like
enter image description here
o/p look like while running sever
enter image description here
please help me out by: displaying n no of node in templates in table format
I want to have a field in a Drupal Webform where users can input some formatted HTML (tables, headers, etc.) Is there a way to do that?
Yes.
The form element is called "Text format." This sounds like a format selector of some kind, but it's actually a text element. If you set it to "Basic HTML," for example, the CKEditor WYSYWIG loads.
The image below is an example (the 'field' labeled Notes/URL(s)). If users wish to enter HTML directly, the code view button in the toolbar allows for that.
Here's what the initial page of the webform config looks like for this element...
I am using Goose to read the title/text-body of an article from a URL. However, this does not work with a twitter URL, I guess due to the different HTML tag structure. Is there a way to read the tweet text from such a link?
One such example of a tweet (shortened link) is as follows:
https://twitter.com/UniteAlbertans/status/899468829151043584/photo/1
NOTE: I know how to read Tweets through twitter API. However, I am not interested in that. I just want to get the text by parsing the HTML source without all the twitter authentication hassle.
Scrape yourself
Open the url of the tweet, pass to HTML parser of your choice and extract the XPaths you are interested in.
Scraping is discussed in: http://docs.python-guide.org/en/latest/scenarios/scrape/
XPaths can be obtained by right-clicking to element you want, selecting "Inspect", right clicking on the highlighted line in Inspector and selecting "Copy" > "Copy XPath" if the structure of the site is always the same. Otherwise choose properties that define exactly the object you want.
In your case:
//div[contains(#class, 'permalink-tweet-container')]//strong[contains(#class, 'fullname')]/text()
will get you the name of the author and
//div[contains(#class, 'permalink-tweet-container')]//p[contains(#class, 'tweet-text')]//text()
will get you the content of the Tweet.
The full working example:
from lxml import html
import requests
page = requests.get('https://twitter.com/UniteAlbertans/status/899468829151043584')
tree = html.fromstring(page.content)
tree.xpath('//div[contains(#class, "permalink-tweet-container")]//p[contains(#class, "tweet-text")]//text()')
results in:
['Breaking:\n10 sailors missing, 5 injured after USS John S. McCain collides with merchant vessel near Singapore...\n\n', 'https://www.', 'washingtonpost.com/world/another-', 'us-navy-destroyer-collides-with-a-merchant-ship-rescue-efforts-underway/2017/08/20/c42f15b2-8602-11e7-9ce7-9e175d8953fa_story.html?utm_term=.e3e91fff99ba&wpisrc=al_alert-COMBO-world%252Bnation&wpmk=1', u'\xa0', u'\u2026', 'pic.twitter.com/UiGEZq7Eq6']
In ac I got the images with their score of similarity in list format. I want to display all images in browser using django. How can I display each image in browser?
ac=obj.perform(newdoc.docfile.path)
for (score,resultID) in ac:
result = cv2.imread(path1 + "/" + resultID)
# cv2.imshow("Result", result)
return HttpResponse(cv2.imshow("Result", result))
From cv2.show("Result",result) a popup window is opened and shows the image but when I go through HttpResponse passing the image to the browser it gives the result None. How can I solve the issue?
You cannot do this by one view. I would suggest to have 2 views. first displays single image using StreamResponse. And second view will have a template where it goes trough every image and has <img> tag which src shows to your first view.
Also you cannot use cv2.imshow(), I'm not cv2 expert but as far as I know that function is for displaying your image in window. In your case you need to read the binary data from your cv2 object and pass it to StreamResoponse object as django response.
Other possible way is to have a template where you create img tag for each your case and put binary data to it as follows:
<img src="data:image/png;base64,{{ base64_data_from_cv2_object}}"/>
I have a view created that displays content type "Gallery images".
I can style this content type in node--gallery_images.tpl.php, but this template is for both gallery images and gallery images in view. I want galleries in view stylize differently than individual gallery.
Display output: views-view.tpl.php, views-view--gallery.tpl.php, views-view--default.tpl.php, views-view--default.tpl.php, views-view--page.tpl.php, views-view--gallery--page.tpl.php
Style output: views-view-unformatted.tpl.php, views-view-unformatted--gallery.tpl.php, views-view-unformatted--default.tpl.php, views-view-unformatted--default.tpl.php, views-view-unformatted--page.tpl.php, views-view-unformatted--gallery--page.tpl.php
Row style output: .tpl.php, --gallery.tpl.php, --default.tpl.php, --default.tpl.php, --page.tpl.php, --gallery--page.tpl.php
I was trying all possible combinations like views-view--gallery--page.tpl.php, views-view-row--gallery--page.tpl.php and so on, including --gallery--page.tpl.php but can't find the right file name. Whats wrong with that?