I am making excel file to get product price from site and compare. So far i managed to parse product name and price. but problem comes when product is on sale, then it had different element as shown below 1 is normal 2 is on sale
1.
<div class="price">
<span>$87</span>
</div>
2
<div class="price">
<del>100</del>
<ins>80</ins>
</div>
I am doning
Set hPrice = hPord(r).getElementsByClassName("price")
for loop
ActiveSheet.Range("H6").Offset(r, 0).Value = hPrice(0).innerText
this work fine for normal product price but on sale product it returns "100 80"
i try to use
If Not hPrice(0).getElementsByTagName("ins") Then
this gives error when "ins" is not present,
pleae let me know how to verify child tag is there or not, or you have better alternative
Thanks
You have forgotten to add index of <ins> tag to your line. This could be something like this:
If Not hPrice(0).getElementsByTagName("ins")(0) Then
in other words, to get the product price value you need to have this line:
hPrice(0).getElementsByTagName("ins")(0).innerText
Try below samples
If Not hPrice.getElementsByTagName("ins")(0) Then
OR
If Not hPrice.getElementsByTagName("ins") Then
Related
<element_1>
<element_2>Text</element_2>
<element_3>
<element_4>
<element_5>Test Text</element_5>
</element_4>
<element_4>
</element_4>
</element_3>
<element_6>
<element_7>
<element_8>0</element_8>
How would I write xpath to find all instances of element_4 that contain an instance of element_5
Context
URL: https://www.amazon.com/b/ref=s9_acss_bw_cg_KOTHLPCG_1a1_w?node=565108&pf_rd_m=ATVPDKIKX0DER&pf_rd_s=merchandised-search-6&pf_rd_r=PASRJV57NJ97XPYZW0GS&pf_rd_t=101&pf_rd_p=1e1598d2-28c3-4a64-91af-254d7a033ada&pf_rd_i=541966\
I am using selenium and I am trying grab the name of only the laptops that are on sale. The laptops that are on sale have an old price that is written with a strike through which is written underneath its current price. I want the names of only the laptops that have that strike through price in their listing.
Very new to Selenium and Xpath so I hope that made sense.
To complete, this will select laptop names on sale (works for all pages, featured items on page 1 excluded):
//span[#data-a-strike="true" or contains(#class,"text-strike")][.//text()]/preceding::h2[#class][1]
I am currently trying to hide specific elements, if the creditUser in my app has credit less than the costs of a specific dish. (It's kind of a dish ordering system, just for training purposes) And I cannot figure out how to set up the thymeleaf condition, to make it work...
I've tried all kinds of solutions, but all I can find on the internet is something like this: th:if="*{ score < 20 and score >= 0}"
my current version looks like this:
<td ><a th:if="${creditUser.credit} > ${dish.small}" class="btn btn-success" th:href="#{/order/orderDish/(creditUserId=${creditUser.id},dishId=${dish.dishId},delId=${dish.delId},dishName=${dish.name},price=${dish.small})}" th:text="${dish.small}">Bestellen</a></td>
Now I don't get any error messages, but the element is also not showing up. Any suggestions on how to compare a value in thymeleaf to another value? (The creditUser is passed it is just not shown in the code part and the solution works with fixed values like creditUser.credit > 1)
Everything should be inside the same braces:
th:if="${creditUser.credit > dish.small}"
I am web scraping a real state page and trying to get the data of name, location, price, etc... in an excel table. This is the code to get that information:
soup = bs4.BeautifulSoup(driver.page_source,'lxml')
for price in soup.find_all('span',{"class":"ann-price"}):
price_list.append(price.text)
for name in soup.find_all('div',{"itemprop":"name"}):
name_list.append(name.text)
for meters in soup.find_all('div',{"class":"ann-box-info"}):
meters_list.append(meters.text)
for rooms in soup.find_all('div',{"class":"ann-box-info"}):
bedrooms_list.append(rooms.text)
for location in soup.find_all('span',{"class":"ann-info-item"}):
location_list.append(location.text)
for realtor in soup.find_all('span',{"class":"company-name"}):
realtor_list.append(realtor.text)
Questions:
Most offers have the company name as span.company-name inside a div.ann-box-contact. The problem is that whenever a special offer appears without a div.ann-box-contact (thus without company name) instead of leaving the space blank it outputs the name for the next offer, harming the excel's format.
Is there any way that I could filtrate those offers by looking for span.company-name specifically inside div.ann-box-contact?
Here is the page's code where the company name and the contact box are:
<div class="ann-box-contact">
<div class="info">
<span class="company-photo">
<span class="user-avatar"></span>
</span>
*<span class="company-name">*
<br>
The element within asterisks is the one I want to get but specifically, look for it inside the div.ann-box-contact in order to ignore any offer without Company-name.
You could find the <div class="ann-box-contact"> first and then search inside to find the <span class="company-name"> with beautifulsoup
Something like this:
div = soup.find('div', {'class':'ann-box-contact'})
span = div.find('span',{'class': 'company-name'})
Importing the CSV with some configurable product, how I can input the different price for every simple product.
You have to use column with heading lable '_super_attribute_price_corr' to input you price for every child product. If you want to add the price simple enter the amout, if you want add the percentage than simply add percentage with percent symbol, Like (10%).
This is an architecture question, but its solution lies in ColdFusion and MySQL structure--or at least I believe so.
I have a products table in my database, and each product can have any number of screen-shots. My current method to display product screen-shots is the following:
I have a single folder where all screen-shots associated with all products are contained. All screen-shots are named exactly the same as their productID in the database, plus a prefix.
For example: Screen-shots of a product whose productID is 15 are found in the folder images, with the name 15_screen1.jpg, 15_screen2.jpg, etc...
In my ColdFusion page I have hard-coded the image path into the HTML (images/); the image name is broken into two parts; part one is dynamically generated using the productID from the query; and part two is a prefix, and is hard-coded. For example:
<img src"/images/#QueryName.productID#_screen1.jpg">
<img src"/images/#QueryName.productID#_screen2.jpg"> etc...
This method works, but it has several limitations the biggest listed bellow:
I have to hard-code the exact number of screen-shots in my HTML template. This means the number of screen shots I can display will always be the same. This does not work if one product has 10 screen shots, and another has 5.
I have to hard-code image prefixes into my HTML. For example, I can have up to five types of screen-shots associated with one product: productID=15 may have 15_screen1.jpg, 15_screen2.jpg, and 15_FrontCover.jpg, 15_BackCover.jpg, and 15_Backthumb.jpg, etc...
I thought about creating a paths column in my products table, but that meant creating several hundreds of folders for each product, something that also does not seem efficient.
Does anyone have any suggestions or ideas on the correct method to approach this problem?
Many thanks!
How about...
use an Image table, one product to many images (with optional sortOrder column?), and use imageID as the jpeg file name?
update:
Have a ImageClass table, many Image to one ImageClass.
Image
-----
ID
productID
imageClassID (FK to ImageClass)
Use back-end business logic to enforce the some classes can only have one image.
Or... if you really want to enforce some classes can only one image, then can go for a more complex design:
Product
------
ID
name
...
frontCoverImageID
backCoverImageID
frontThumbImageID
backThumbImageID
Image
-----
ID
productID
isScreenShot (bit) // optional, but easier to query later...
However, I like the first one better since you can have as many classes you see fit later, without refactoring the DB.
Keeping information on how many and what images in the database is definitely the way to go.
Barring that, if you want to use naming conventions to associate images with products, and the number of images is arbitrary, then it's probably a better idea to create one folder per product:
/images/products/{SKU1}/frontview.jpg
/images/products/{SKU1}/sideview.jpg
/images/products/{SKU2}/frontview.jpg
and so forth. Then use <cfdirectory> to collect the images for a given product. You might also want to name your images 00_frontview.jpg, 01_sideview.jpg and such so that you can sort and control what order they'll display on the page.
use the cfdirectory tags to inspect the filesystem:
<!--- get a query resultset of images in filesystem --->
<cfdirectory action="list" name="images" directory="images">
<!--- get images for specific product --->
<cfquery name="productImages" dbtype="query">
select *
from images
where name like '#productid#%'
</cfquery>
<cfoutput query="productImages">
<img src="#productimages.directory#/#productimages.name#" />
</cfoutput>
You could even try using the filter attribute to cfdirectory to try and omit the QoQ