Pulling Django variable data using Python - python-3.x

I am currently working on a project to grab live match data for eSports (yeah I'm a nerd, aren't we all?). So I am pulling HTML from a page and checking if my favorite team is playing and if so, go the page and check the scores every few minutes to get updates. The part I am now having trouble with is getting the names of teams and the match ID's. The reason for this is because when I grab the HTML data, inline JS variable names are included instead of their values which is what I need. Here is an example of what I am talking about:
<div class="col-xs-12 schedule-{[{schedule.state}]}" ng-if="schedules.length>0" ng-repeat="schedule in schedules track by schedule._id">
I need a way to grab the value of "schedule.state". Hopefully you guys can help. Also if there is already a similar solution I would be happy to be directed to it! Cheers!
EDIT
I have just realized through a little more researech that the variables are not JS but Django. Given the same problem just on how to get Django variable data instead of JS.

Related

Can you populate word fields from a react app using pdftron?

I was wondering if anyone could point me towards a solution to my issue with pdftron/webviewer. I am building a MERN app and one of the projected feature is contracts generation. I created my fields in .docx file, loaded it in with webviewer.
I tried:
having my data collecting form on the same page with webviewer and passing data via state. (...yeah)
Tried to separate contract generation page and display (webviewer) page and use localStorage/redux.
Lastly I tried to take advantage of my database, so I created new model/schema and set up the collections that on the form page the contract data gets POSTed into database and then fetches from the webview page. Mongo has a TTL flag to remove every record after 1 minute.
I can console.log(contract.name) but it just won't consistently show as {{NAME}} (consistently because on several ocassions it works..)
Any help is greatly appreciated. Can't provide console errors log/network dont show any.
It seems like you are trying to fill forms with data. You could check out this guide for form filling. PDFTron JavaScript PDF form filling library
This is an live example showing how it would work.
Let me know how this works for you.

NetSuite Saved Search Print Criteria Information

I would like to be able to print the Criteria information that I used in the footer of the PDF of a Saved Search. I have tried looking at making an Advanced PDF to handle this, but I cannot find the field to pull in the criteria information into either the Saved Search or the Advanced PDF. Any assistance would be greatly appreciated.
Edit: I have created a Saved Search in NetSuite that displays all of the Inventory Receipts made the previous week. We have to print this Saved Search and check it against the actual paper receipts to verify counts and receipts. When the Saved Search prints to PDF it does not show the criteria information for which the Saved Search was run to prove to Internal Audit that we have run this report for the correct dates. I would like a way to print the Criteria information for this Saved Search along with a timestamp of when the Saved Search was run and the users that ran the Saved Search. Is there a way to pull in this additional information in a Saved Search or Advanced PDF somehow?
add a custom Print button
button goes to a suitlet that renders the PDF
before you render, load the search and pass the search.filters in to addCustomDataSource() api of the render module
Ok, I read your edit and comment with regard to my comment. There's three big things here.
I don't think you should pursue a dev route with this. You can schedule the report for automated email once a day and prove that it came from a saved search which is the same saved search every time. This will save you an infinite amount of hassle
Developing this as your first script is going to be hard. I'm happy to help. But when I tell you it's going to be a lot of code, I mean it. See this old post I did https://stackoverflow.com/a/61066928/11323304
If you still want to pursue a dev route with this (which is totally fine), start with emulating the user event code on a custom suitelet like I posted above in my answer. You're going to need N/serverWidget/ui N/search and N/xml. The rest is all in the UserEvent functions and global context variable.
If all this still goes well over your head. Don't sweat it. Comment back, and we'll build something step by step. But, I highly, highly, highly encourage you to check out the automated email capabilities of NetSuite before trying to develop something special.

Need Direction - Web Bot Creation

I want to create something that will look at a specific location on a website and read the value at this location. Then take that value and put it into a already created block of text.
What do I need to start researching to create something like that? Simple direction such as key words to Google and such would be extremely helpful.
Do you want to get the value from your own website or someone else's website?
If you want to get the value from an HTML element, you can easily do so using Javascript/jQuery.
If you are looking to write a script that parses the HTML from somebody else's website, you will need a HTML parser. If you plan to use Python, look into Beautiful Soup.

Search Algorithm for a web application that needs to look for a specific value

I'm developing a webapp that will need to download the html form a website and then iterate through the code and try to find a specific but ever changing value (in our case it will be the price for the product).
For this, I was thinking about asking the user (upon installation and setup) to provide the system with a few lines of html from the page (that has the price) and then from then on, every time we need to fetch the price we would try to search for those lines and find the price.
Now, I believe this is a horrible and slow way of doing this and since there are no rules and the html can be totally different from one website to another (even the same website might change) I couldn't find a better way.
One improvement that I thought about was to iterate through the first time and record the line at which we find the code. Once found, the subsequent times we would then start from a few lines before the expected location and start the search. Any Thoughts on how I can improve on this?
I posted this question on https://cstheory.stackexchange.com/ but they commented that it's not on topic and that I should post it here.
I have the code for the above and if needed I can post it, I'm simply thinking that there must be a better, faster way of doing this.
This is actually something I tried for a project recently (using BeautifulSoup and Python). The solution that worked for me was to workout CSS selectors (which can map to jQuery selectors) that targeted the elements that contained the values I was looking for. In my case I was able to narrow down the full document to just the elements that contained what I was looking for but if you couldn't get exactly what you where after you could combine this with some extra lactic like test to see if it looks like a price (via regex) or test what it is next to.

Cannot locate a text_field with dynamic id

<div id="temp_1333021214801">
<input type="text"/>
</div>
$browser.text_field(:xpath,".//*[#id='temp_1333018770709']/input").set("apple")
I am getting error "unable to locate element", because the ID changes dynamically.
Please help me to set the text in the text field.
It seems like your dynamic id is temp_ so this should do it given information above:
browser.div(:id, /temp_\d+/).text_field.set 'something'
Issues with my solution is that it assumes id will always be temp_ regex matching any number set consecutively, which seems to be the case with your sample above. Also, it assumes there is no other div(:id, /temp_\d+/) combination in the DOM of that page, most likely should not be an issue.
If you have dynamic IDs I can suggest the following:
Code to object counts. For example
$browser.text_field(:index => 2)
gives the third text_field on the page.
Code to what is around the thing you're trying to find.
$browser.div(:name => 'mydiv').text_field(:index=>2)
gives the third text field in the div called 'mydiv'.
HOWEVER
If your front-end is less-than-testable in this way I highly suggest you put time into thinking over your commitment to automated testing in the first place. Any minor change to the software is going to have you working until 9pm pulling your hair out and rocking back and forth as you update all your scripts, so unless code maintenance is your weekend hobby think about semi-automation or exploratory testing or manual scripts. Talk to development (whomever that might be. It might be you!) or the higher-ups (unless that's you too) to see if it can be made more testable. Also don't use xpaths unless you take some deviant pleasure in it.
Hope that was helpful, I can't do anything specific without the source HTML.

Resources