Web Scrape returns N/A, not sure how to keep the data returning - xpath

totally new here & figured you guys will know the answer before I can even come near figuring this out.
I have a google form, feeding a live google sheet which users submit car reg numbers.
My goal is to have the reg number display the make, model besides the reg.
I have implemented an importXML function & the cell I expect to see the data loads up for a few minutes, then reverts to "N/A" or sometimes doesn't pull the data at all, but manually visiting the URL does return the data.
The import XML function uses a cell, made up of URL string, then adds the Reg/VIN input by form submission. That cell looks something like this "basicvehicledetails.com/reg" and returns the Class on the webpage relevant for Make/Model in separate cells.
I need the data to stay once it is returned, but don't know how to do that.
Another option is a car check website that requires a login, and then the reg to be input & searched before a webpage returns in-depth data on the car, is this something I can get to export to google sheet/excel spreadsheet?
I'm really stuck for this one, and would really appreciate any help as updating each car manually is painful.

try like:
=REGEXREPLACE(QUERY(ARRAY_CONSTRAIN(IMPORTDATA(
"https://www.motorcheck.ie/free-car-check/?vrm=152D1234"),5000,1),
"where Col1 contains 'dark-left'", 0), "</?\S+[^<>]*>", )
UPDATE:
=IMPORTHTML("https://www.cartell.ie/ssl/servlet/beginStarLookup?registration=152D1234",
"table", 1)

Related

JavaScript: how to trigger update form after setting input

I am writing a simple App Inventor program to populate a Covid-19 school health check page. I am stuck on selecting a school. Normally you type in a school name, the page finds string matches and you select from the list of string matched school. I am able to simply set the field manually but the rest of the form doesn't update. I know I must trigger an update but I cannot make head or tails of how this page works.
image of school selection
typing in part of school name
From the Chrome console I can do the following:
x = document.getElementsByClassName("k-textbox")
x[1].value = "Horace"
From the picture you can see the text was updated to "Horace" but the results have not updated. What should I do to force an update so the results list shows proper matches? Also, how do I query the matching results so I can confirm that my input was explicit enough to return a single match? FYI, this form entry page will be hidden to the user.
You can get the kendoDropDownList, call the read method from it's dataSource, and pass the locationName value of what you want. This won't set the text in the textbox, but it will filter your list down like you want.
To test, click on the input, open your console, and run the following:
$('#Location').data('kendoDropDownList').dataSource.read({ locationName: 'horace' })

Form and availability of "formers"

I am stuck on a problem that I did not think before.
I have a form formers with 3 fields (name, firstname, status).
Then, my second form is the trainings with 2 fields (date_sitting, fk_former).
Here, I have 1 sitting date -> 16/07/2019 and the former is Dujardin Luc.
Now my problem is that if I want to create a new sitting for on 18/07/2019.
How to do for that the former Dujardin Luc to be available in my dropdownlist for on 18/07/2019 or another date??
Is it, in my case, I must to create 2 files create.blade ?
The first will just have a field -> date_sitting
And the second form will have the field -> fk_former ?
Here is my TrainingController for information
public function index()
{
$trainings = Training::oldest()->paginate(5);
$formersNoTrainingToday = Training::whereDate('date_sitting', "!=", Carbon::today())
->orWhere('date_sitting', null)->get();
$formers = Former::doesntHave('trainings')->get();
return view('admin.trainings.index', compact('trainings'))
->with('i', (request()->input('page',1) -1)*5);
}
I can't give you the whole answer, as there are too many things to update and a few things to decide.
First, you'll need to change your index() method to both send more and different data. If a former can train on multiple days, the $formers = Former::doesntHave('trainings')->get(); is no longer valid -- you want all formers now so that you can add a new date. So just $formers = Former::get(); now.
Next, your $formersNoTrainingToday is now obsolete, as you don't want to identify those who are unavailable just today, you want a list of all training dates so compare against whatever date the user is looking for in the form. Example: If Dujardin Luc wants training on 18/07/20XX, we don't want him in a list of NoTraining because we want him available, even if he is unavailable today.
Last on the controller side, depending on how you want to do the blade side, you might want to include a variable for an AJAX date to use to send through those formers who are available on the specific date requested by the user through AJAX. For example, if you go through AJAX, you might have a method to just send those available on the date requested like this in your controller (Not exact code):
public function getFormersWithoutTrainingOnDateRequested($dateRequested){
$formersAvailableToday = Training::whereDate('date_sitting', "!=", Carbon::createFromFormat('Y-m-d', $dateRequested))
->orWhere('date_sitting', null)->get();
return json_encode($formersAvailableToday);
}
The next part is on the blade side. You have quite a few choices here, but both of the ones I recommend involve some type of JS or Jquery. In order to populate the list of formers for the day that the user requests, for best user experience, you should get them the list quickly.
Fastest would be to provide a list of trainings (date_sitting, fk_former) to the page from the index. This would be stored as a data-object on some element of the blade page. Then, when the user clicks to change the date, a JS or Jquery function would pull the list into a var, compare it against another list of former's ids stored the same way, and re-write the select list immediately, using only those formers whose ids were not matched for the date.
Second way to do this would be a little slower, but a little easier. It would involve going back to the server to get the list of formers available. So you would have an AJAX function on the same select that goes back to the server to pull those formers available on the date chosen. The success() method of the AJAX pull would provide the info to re-write the select box, or perhaps even re-make the whole form.
Sorry I can't write all the code, you'll have to fill in the blanks where you can, but this is hopefully enough to help you figure out where to go.

swift : display info to a users (first use) and then disappear

I would like to display some info on the screen ... which will disappear.
Example : an Uiview is displayed for the first time to an user (or feature never used by the user). I would like to display on a screen a label or an image to explain how to use this new feature. After that it will disappear ...
If this functionality has already been used by the user, the message is ofcourse not displayed.
example of message --> to add a gamer, press +
How to do that ? a lot of apps have this kind of help.
thanks
What you have to do is actually very simple : have a persistent variable, and change its value. Each time the user could see the help popup, you check the value of the variable you stored persistently. If this variable indicates that the user have already seen the help, you don't display it again. Otherwise, you show it. Simple example:
let helpSeen: Bool = getVarFromPersistent()
if helpSeen == false {
// DISPLAY THE HELP MESSAGE OR POPUP
setHelpSeenVar(true)
}
Where getVarFromPersistent() and setHelpSeenVar() are function you could create to respectively retrieve the variable from the persistent data and set the variable in the persistent data.
Now, you have to figure out how to use persistent data. You can have a look at CoreData, that is provided by Apple and "ready to use" in Xcode. You've probably already seen the use core data tickbox when you create a project.
Third party libraries exists as well like RealmSwift, who reached version 1.0 recently.
I'm not an expert, but I think Realm is simpler to use than Core Data. The technology used by the two libraries could be different though, maybe someone else could tell you more about it. Anyway, you will find a lot of article about Realm and Core Data on Google.

Forcing JQuery Datatable to load data via AJAX upon selection of a date range

I have the wonderful jquery data tables currently loading data using ajax.
The code is pretty much the same as the example I took it from which can be found at: http://www.datatables.net/release-datatables/examples/server_side/pipeline.html
I found this the best example because it incoporates pagination, sorting and also the search box into the ajax requests. The search box allows you to type in key words and this triggers the ajax function which includes the search value as a $_GET var to the server script.
This is a small preview of my table with table tools etc. loaded.
http://img828.imageshack.us/img828/9778/previewxjh.png
As you can see the main focus here is the filament groups date range plugin which I have added. I have finished with this now, and have a fail safe for the duplicate event firing problem etc. its ready to go and just needs including in the ajax pipeline - which is where I have been stuck for the last day or so.
fnDataTablesPipeline appears to be just an interim and doesnt reference the search box at all, so I can't figure out how the search box is working, and I am unsure if this is the right place to go including my date range value (everything I have tried just leads me to a dead end)
I want to use my onChange event for the date range filter, and apply it exactly the same way that the search box works. When the value is changed, simply pass it as a get variable so that my php script can deal with it there. I have concerns regarding the paging, and I will probably need to just reset back to page one after the date is changed (not sure how I am going to deal with this just yet, but thats the next step)
I need help telling datatables to refresh from the ajax source, and include the date range as a get parameter to the server side script (like when the search box value changes)
- sounds straight forward, but this is where I am breaking down and not making good use of my time due to the lack of understanding.
Is there anyone that has implemented similar that can help me?
The biggest problem right now is how to force the refresh from my date range onChange event, and of course include the single string value which contains my dates (which I know how to cover server side)
Many Thanks,
Chris
EDIT: I actually managed to get this working before I finished for the day. I'll post my code when I get back in the office tomorrow, it was actually surprisingly easy - I was tackling it completely wrong.
After changing date..
oTable.fnClearTable(0);
oTable.fnDraw();
Include var in pipeline
function fnDataTablesPipeline ( sSource, aoData, fnCallback, dateRange ) {
aoData.push( { "name": "dateRange", "value": $('#dateRangePicker').val(), } );
...
Obtain var in php script
$_GET['dateRange']

Getting a blank data report vb6

I am new to vb6. I am working to create the invoice generation application. I am using data report to show the generated invoice.
The step by step working of process is:
Entering the data in to Invoice and ItemsInvoice tables.
Then getting the maxId using (Adodc) from the data base to show the last generated Invoice.
Then passing the max Id as parameter to the data report which is showing the invoice according to the invoice id.
It is working fine when I first time generate invoice. Now for 2nd invoice without closing application I am getting a blank data report. For data report I am using dataenvironment.
I am guessing the reason the data report is blank is because there was no record for that Id, but actually the record is inserting in the database.
What is going wrong?
I'm not sure how your data set is getting configured, but it sounds like you have a single record in the data and aren't reloading it properly. If your report is manually moving through the recordset and only showing info based on the ID parameter you are passing it and then using the same recordset for the second report, you probably just need to MoveFirst on the recordset to put it back at the beginning.
Load the data environment and refresh the data report.
I am also generating report in the similar fashion. I faced this problem. Here's the solution
Load DataEnvironment1
With DataEnvironment1
'Command1 is the command added to data environment where you fire query or
'set it to point to a table
If .rsCommand1.State <> 0 Then .rsCommand1.Close
.Command1 maxid 'parameter you pass to the recordset
End With
DataReport1.Refresh
DataReport1.Show
Thats it!
You are done. I m sure it will work. Do tell me if it doesn't.
I don't know if the answer will still bother you, but if someone else have the same problem here is a example of how the problem works:
Imagine that there is a gate and a guard looking who is entering, when the first person (the first invoice) comes, the guard registers him, opens the gate (This is the event "Load DataEnvironmet") and then lets the guy pass. The guard believes that no one else would come and lets the door open (the instruction believes that the DataEnvironment ends and the value EOF becomes True), but when the second guy comes (the second invoice) the guard can't ask him who is (has, again, the value and lets it pass without registering him (this is the reason why the second invoice, and subsequent in while invoice would come blank). The solution is to close the gate ("Unload DataEnvironment") after a guy passes (After showing the data report).
The solution is the code given from Sangita above, but just before ending the sub you need to unload the DataEnvironment you were working on.
For me, it works. Sorry if the answer is not what you were looking for (and also if someone else can't understand what I'm writing, my English isn't very good). Just in case I will write the code with the solution
Load DataEnvironment1
With DataEnvironment1
If .rsCommand1.State <> 0 Then
.rsCommand1.Close
End If
.Command1 Value(ID)
End With
DataReport1.Refresh
DataReport1.Show
Unload DataEnvironment1
Try a refresh method like data1.recordset.requery or
Data1.refresh. This should work if you use data controls.

Resources