Here I'm Scraping the site https://hamrobazaar.com/c6-apparels-and-accessories and i want to store all the sub-categories details in a bean and print them. If i got the details of object accordingly than this also would be much help.
Example:
I want to Scrape Name of the Mask as Kn95 Mask (fda Certified), description as We are Seller..., seller name as Birodh Pokhrel, Address as Damak-5,Damak, price as 210, date, and type as Brand New
If you are good at Jsoup, and Xpath. Please help me to obtain this. Thank You
For the XPath part (jsoup doesn't support it, so maybe you can try with xsoup) :
Some selectors to grab the details from the ads, including the one with yellow background which stays the same for each page. (article title, description, seller, address, price, item condition) :
//font[#style]/b
//b[.="Seller:"]/preceding-sibling::text()[normalize-space()]
//b[.="Seller:"]/following-sibling::a
//b[.="Seller:"]/following-sibling::font
//b[starts-with(.,"Rs.")]
//b[starts-with(.,"Rs.")]/following-sibling::font
Number of elements for each detail : 21
Some selectors to grab the details from the ads, excluding the one with yellow background which stays the same for each page. (article title, description, seller, address, price, item condition) :
//font[#style][not(ancestor::table[#id])]/b
//b[.="Seller:"][not(ancestor::table[#id])]/preceding-sibling::text()[normalize-space()]
//b[.="Seller:"][not(ancestor::table[#id])]/following-sibling::a
//b[.="Seller:"][not(ancestor::table[#id])]/following-sibling::font
//b[not(ancestor::table[#id])][starts-with(.,"Rs.")]
//b[not(ancestor::table[#id])][starts-with(.,"Rs.")]/following-sibling::font
Number of elements for each detail : 20
Side note : be careful with item condition. Some ads are missing this field. So, the number of elements could be lower than 20 or 21.
I'm creating a simple script to visit priceline.com and then searching "N" under Departing Flights and selecting New York City (NYC) from the dropdown list.
My code successfully types into the search bar but is still unable to find the dynamic dropdown with all the relevant results. I am not sure why.
// Clicks on "Departing from?" textbox and clears it before typing 'N'
driver.findElement(By.id("flight-departure-airport0")).click();
driver.findElement(By.id("flight-departure-airport0")).clear();
driver.findElement(By.id("flight-departure-airport0")).sendKeys("N");
// Store all dynamic search results into a list
List<WebElement> departureDropdown = driver.findElements(By.id("//*['flight-departure-airport0-dropdown']/div/div/div"));
System.out.println("List: "+departureDropdown);
Expected:
I expected departureDropdown to have a length of 9 with various airports. (Nadi, New York City, Nagasaki, etc) and expect departureDropdown[i] to return one of the city names in plain text.
Actual:
My code is stuck at the list initialization. departureDropdown is empty.
You have used By.id but you have created xPath.
Try with below xPath
List<WebElement> departureDropdown = driver.findElements(By.xPath("//div[#id='flight-departure-airport0-dropdown']//div[#role='option']"));
When I use label:sent as a search query in the gmail UI it takes me to sent items but when I use a labelId of sent from the gmail API for messages (https://developers.google.com/gmail/api/v1/reference/users/messages/list) I get an error "Invalid label: sent" - just wondering how do I query for sent items from the API? Also is there a reference / examples for the type of input you can use for the "q" input parameter for the gmail API?
Thanks
If you're doing a list with "?labelId=" then use "SENT" (in upper case) as per:
https://developers.google.com/gmail/api/guides/labels
(those should probably be case insensitive but they are not.)
For the "?q=" parameter to the list methods it says on the URL you give:
Supports the same query format as the Gmail search box. For example, "from:someuser#example.com rfc822msgid: is:unread".
For more examples, I just tried searching for "gmail search queries" and got:
https://support.google.com/mail/answer/7190?hl=en
which gives lots of useful keywords, they should all work with the "q=" parameter (you may need to URL escape them, depending on language/client libraries).
I've done my best to find the answer, but nothings seems to cover what I'm trying to do. I know how to get a single feed, from say a fan page like Starbucks, or Pepsi using the Graph API. What I want to do is get several, or multiple, feeds in a single request. Is this possible? I was told by another developer that it is, but haven't found anything on this subject in the FB documentation, or anywhere else online. I have like 50 feeds I want to aggregate into a single feed, and I don't want to make 50 different requests to get all that data.
Has anyone know how to do this, or know if it's even possible?
Thanks.
After ever MORE searching, apparently you can do this. You do this by using Batch Requests:
https://developers.facebook.com/docs/reference/api/batch/
Hope this will save someone time in the future :)
Looks like you can't really.
This works:
SELECT page_id
FROM page
WHERE username='facebook'
OR username='coca-cola'
{
"data": [
{
"page_id": 20531316728
},
{
"page_id": 40796308305
}
]
}
This works (~100 results):
SELECT post_id,message
FROM stream
WHERE source_id IN (
SELECT page_id
FROM page
WHERE username='facebook'
) LIMIT 100
But this doesn't really works (3 results):
SELECT post_id,message
FROM stream
WHERE source_id IN (
SELECT page_id
FROM page
WHERE username='facebook'
OR username='coca-cola'
) LIMIT 100
I have developed code as below.
jQuery(document).ready(function(){
jQuery("#records").jqGrid({
height:350,
datatype: 'local',
colNames:['Policy Name','Policy Type', 'Time allowed (HH:mm)','Expiration Duration (days)','Session Pulse(minutes)','Description'],
colModel :[
{name:'pName', index:'pName', editable:true,sorttype:'text',width:150,editoptions:{size:10},formatter:'showlink',formatoptions:{baseLinkUrl:'javascript:' , showAction: "GetAndShowUserData(jQuery('#list2'),'",addParam: "');"}},
{name:'pType', index:'pType', sorttype:'text',editable:true,width:150,editoptions:{size:10}},
{name:'timeAllowed', index:'timeAllowed', sorttype:'text',editable:true,width:200, align:"right",editoptions:{size:10}},
{name:'expDuration', index:'expDuration', sorttype:'text',editable:true,width:200, align:"right",editoptions:{size:10}},
{name:'sessionPulse', index:'sessionPulse',sorttype:'int',editable:true,width:200, align:"right",editoptions:{size:10}},
{name:'description', index:'description', sortable:false,editable:true,width:200,editoptions:{size:10}}],
pager:jQuery('#pager'),
rowNum:10,
sortname: 'pName',
autowidth:true,
altRows:true,
drag:true,
sortorder: "asc",
rowList:[2,5,10,20],
viewrecords: true,
loadonce:false,
multiselect: true,
/*
onSelectRow: function(id){
var gr = jQuery("#records").jqGrid('getGridParam','selrow');
if( gr != null ) jQuery("#records").jqGrid('editGridRow',gr,{height:280,reloadAfterSubmit:false});
else alert("Please Select Row");
},
editurl: "server.php",
*/
caption:'Manage Policy'
});
});
Now, I want to make an Ajax request to the servlet for next records when the user presses >> the (next) button of the jqGrid. I have searched much on the Internet, but I found a lot of PHP code, but I can not understand that PHP; I want to develop that thing in Java. How can I do that?
As GPS said, the paging in jqGrid works by paging through its current dataset. You have to load a big set of data, and it will page through that dataset. There may be a way to get it to behave the way you want, but I don't know how.
For my grids, I use the pagination plugin to trigger an Ajax call to get the next page of data. When the data comes back, I just clear the grid (clearGridData) and add the new set of data using addRowData.
I'm a .NET programmer, so I don't know how you'd do the database calls in with Java, but that's not really a jqGrid question.
To determine how many pages there are, you take the count of all the records that you'll be paging through and divide that by the number of records you will show on the grid per page.