I'm scraping image urls and text from tables and I want to know how to collect nothing (or at least no url) for a cell whose image is missing. I don't want to remove any rows since I want to reproduce the table as is. Here's an example of a table with missing images and the html to the right.
I'm using the following in google sheets:
=importxml(D1,"//div[#class='colsx immagine']/img/#src")
=importxml(D1,"//div[#class='coldx domanda']")
which works fine to get the image urls and text for each row if the images are all there (as on this page). But if any images are missing then I collect an url for the (wrong) image below in the table. I want to skip url collection if there's no img url.
I just starting to learn xpath, and I suspect I need to use the | or not to fix this, but need some help because nothing I've tried works.
Thanks
You can solve this by adding another predicate. So assuming that you want to list the URLs of the //div[#class='lista'] with an image, you can use
=importxml(D1,"//div[#class='lista' and div/img]/div[#class='colsx immagine']")
=importxml(D1,"//div[#class='lista' and div/img]/div[#class='coldx domanda']")
=importxml(D1,"//div[#class='lista' and div/img]/div[#class='coldx risposta active gius']")
and so on.
This should skip all class 'lista' div's without an img tag and select its URLs.
Related
I need to click a link in a grid that contains a particular img on the same row. I can easily find the correct img I want with:
//img[#src='./assets/images/not_evaluated.svg'].
However, when I issue the click with it, it doesn't work because the image is not clickable. However, the same row contains the link I want to click. The xpath to the clickable link is:
//a[#class='veracodelink']//span[contains(text(),'Static Scan')].
I need to combine these 2 xpaths to get the correct link to click. I have tried many different things and combinations, but nothing seems to work.
Assuming that the image and the link are inside the same tr element, you could combine them like this:
//tr[.//img[#src='./assets/images/not_evaluated.svg']]//a[#class='veracodelink']//span[contains(text(),'Static Scan')]
Explained: //tr[...] here selects the correct row containing the image, and the rest then selects the clickable element relative to that.
If they are inside something else than tr, adjust accordingly.
So I finally figured this out myself: The xpath I needed is:
//div//vc-link//a[#class='veracodelink']//span[contains(text(), 'Static Scan')][../../../../../..//img[#src='./assets/images/not_evaluated.svg']]
Using BIRT. Added Image in a Grid. Unable to put label and data fields over image in certain region. Please advise if you achieved it.
Thanks,
Yasar
I think all you can do is use the image as background-url. AFAIK this only works for images that actually come from an URL, but not for images that come from e.g. a database BLOB (but you might download the BLOB to a temporary file and use the file name as URL).
I am unable to get xpath to fetch colors for walmart page. Here is my xpath (//div[#class='js-product-variant-row product-variant-row']/#data-id)[2].
http://www.walmart.com/ip/44786488 - for this walmart page.
Here Iam getting many swaches in color,I want to know how to take all colors in different urls
(for example)I have walmart page, in that there are two types of color for that product page(Black and White). For Black I need separate url and for White I need separate url. I need both color as different url.
Kindly help me
Even though, your question is not much clear, I somehow tried to understand your point and thought, below might resolve your problem. If not, pls specify your exact problem, that you wanted to fetch.
If you need all the colors, below gives the title attributes specifying the color name.
//*[contains(#for,'actual_color')]/span/#title
If you need only names of all the colors, try below.
string(//*[contains(#for,'actual_color')]/span/#title)
Im using play framework and rendering PDF usin rednerPDF() method.
I would like to display some part of content always be in new page.
For Example I have two tables, One table should be in first page and another table should in next page instead of continue from first page. The first table contents are dynamic and we can't sure the height of the table.
Is it possible?
Is it possible?Yes.
You said one table(first one) should be in first page,and again you said its content is dynamic.Now my question is it span over pages and in the next page you want to write second table?This is a generic scenario and what you mentioned is specific one.
You can start trying using two properties of PdfPTable setSplitLate() and setSplitRows()(just google it out for details read Itext In Action).Just keep Two table as two Rows of outer table.set those two property for inner as well as outer in some way as you want(i.e generic case/Specific case).
Another alternative way is use writeSelectedRows() method over PdfContentByte(I don't konw which Object you gonna use for manipulating pdf but you can get it from PdfWriter,*PdfStamper* by using getDirectContent/*UnderContent*/OverContent) after generating table.To use this method you have to set total width of the table so the height can be calculated by method getTotalHeight of PdfPTable.If You use this height properly you absolutely know where your table ends.But all these specific part you have to read & understand first.
With yahp you can use a special html tag to force a page break
<yahp:pb />
we can achieve this by page-break-after:always
Please refer
Alternate to PDF for dynamically generated document with page breaks
Problem
I'm doing some maintenance and changes on a Drupal site, but I'm not an expert. My problem is the following. I have a view that produces an HTML table by fetching some field values and putting them into the table columns. One of these field is an image. Unfortunately each image has a different size (images are uploaded by users), and so the overall table looks ugly. I would like to resize/scale images so that they all have the same width. I know I can use CSS to set the image width to a fixed value, and let the height adjust accordingly:
<img src="..." style="width:70px"/>
Unfortunately I don't know how to make Drupal output this custom HTML when processing my view. Currently the produced HTML looks like this:
<img
class="imagefield imagefield-field_imgsmall"
width="100"
height="39"
alt=""
src="http://www.mysite.org/sites/default/files/foobar.png?1292948397">
and I guess this is produced by one of the view's fields (namely field_imgsmall).
First question is: what is that number after the ? in the src URL? And where does it come from? (Each image has a different number in the corresponding src URL)
What I've tried
I've noticed that in the "edit view" mode, when selecting a field, I can check the option Rewrite the output of this field, and there I can mix HTML and substitution patterns. However, I've seen that one of the substitution patterns that's available to me ([field_imgsmall_fid]) is actually producing the entire HTML above ... so I can't customize it.
What can I do? Am I going in a totally wrong direction?
You should look into the imagecache module, which allows you to resize images (and cache the results, so the resizing process rarely happens).
Here's a walkthrough:
http://2bits.com/articles/drupal-using-imagecache-with-views-and-cck-imagefields.html