Does MATLAB have a function to write data / text to a specific field on a website

5 ビュー (過去 30 日間)
Stephen Hummel
Stephen Hummel 2021 年 12 月 26 日
コメント済み: Sivani Pentapati 2022 年 2 月 22 日
I want to write data to a website (https://rnacomposer.cs.put.poznan.pl/) that requires seperate lines of text. I want to test it out first doing one at a time and then switch to the batch file method. Does MATLAB have functions already developed to write to a website in this manner?

回答 (1 件)

Tanmay Das
Tanmay Das 2021 年 12 月 28 日
Hi,
You may use the "webwrite" function to write data to a website. You may specify field name and corresponding field value to fill the data in that particular field. Here is an example for your reference:
thingSpeakURL = 'http://api.thingspeak.com/';
thingSpeakWriteURL = [thingSpeakURL 'update'];
writeApiKey = 'Your Write API Key';
fieldName = 'field1';
fieldValue = 42;
response = webwrite(thingSpeakWriteURL,'api_key',writeApiKey,fieldName,fieldValue)
  2 件のコメント
Stephen Hummel
Stephen Hummel 2022 年 1 月 13 日
I was trying to implement the webwrite function using a struct for the data to be input into the primary field. However, I consistently recieved an error. Is webwrite the best option for this process? Or do I have the weboptions constructed wrong? I am trying to get this simple test case to work so I can build a larger function to run batch files. Thank you.
The code I used was:
url = 'https://rnacomposer.cs.put.poznan.pl/';
TestSequence =
struct with fields:
Name: 'TestSequence'
Sequence: 'GCUCCUAGAAAGGCGCGGGCCGAGGUACCAAGGCAGCGUGUGGAGC'
Structure: '(((((.......((((..(((..........))).))))..)))))'
weboptions.KeyName = 'input';
weboptions.KeyValue = TestSequence;
options = weboptions;
>> response = webwrite(url, options)
Sivani Pentapati
Sivani Pentapati 2022 年 2 月 22 日
Hi Stephen,
The Media Type for a structure has to be set to 'json' in the weboptions as you are passing a structure in webwrite function. Please find the below code to write the TestSequence structure as JSON object.
url = 'https://rnacomposer.cs.put.poznan.pl/';
TestSequenc.Name = 'TestSequence';
TestSequence.Sequence = 'GCUCCUAGAAAGGCGCGGGCCGAGGUACCAAGGCAGCGUGUGGAGC';
TestSequenceStructure: '(((((.......((((..(((..........))).))))..)))))';
options = weboptions('MediaType', 'application/json');
response = webwrite(httpsUrl, employee, options)

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeCall Python from MATLAB についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by