您的XPath无效。您可以尝试
info_shelf_life = wd.find_element(By.XPATH, '//p[span="Shelf Life"]/following-sibling::div').text
info_country_of_origin = wd.find_element(By.XPATH, '//p[span="Country of Origin"]/following-sibling::div').text
获取所需的数据
我正在Ubuntu上运行Apache,我的问题是 /etc/apache2/mods-available/php5.conf
文件丢失了这一点:
<FilesMatch ".+\.ph(p[345]?|t|tml)$">
SetHandler application/x-httpd-php
</FilesMatch>
我将其添加回了,PHP是正确解析的PHP文件。
局限性
MVC是一个非常广泛的话题,具有不同的理解,因此仅通过术语,即使在PHP应用程序的背景下,也很难正确回答。通常,您会参考MVC的现有实现,这不是您想自己做的情况(提示:读取可用的现有实现代码,以及您想了解更多信息)。
话
虽如此,您可以在答案结束时找到一些实用的“下一步”建议。
但是我也读到您的问题,即您担心HTML模板,也许这与您的示例如何有什么关系。因此,我开始就视图进行无约束力的讨论,然后转到路线和控制器。我主要关注讨论的模型层,至少您必须面对第三方库,否则您的应用程序结构将不会成为广泛功能的好主机,因此可以自动加载。
我在MVC中没有权力,我只使用了PHP中的一些早期实现,并且受其影响的应用程序,但从未完全实施。因此,请勿从讨论中读出任何建议,而仅仅是关于您的榜样以及我在PHP方面想到的。归根结底,您会找到自己的编程问题的答案。
我们走吧。
首先是建议/假设:您当然不想用控制器类实现视图创建,而是使用 View 类实现。控制器不“关心”它不会改变太大(MVC = Model View Controller)。
您可以通过引入 view 类并将 Controller :: createView()
移动到 view :: create(creation()> (比较:提取/移动方法)。
然后,使用 require_once
- 虽然它可以正常工作 - 仅当模板文件仅使用一次时才能工作。这当然不是您想在此处表达的内容(在讨论的后面,我们将看到现有示例也可以比有意想象的更容易发生),而是使用 requiend require
(或<)代码> include 取决于您要处理错误的方式),因为它们将始终在文件中执行代码(有关重新定义控制器的潜在问题,请参见讨论第一次路由,然后在第二个自动加载中)。
除了明显的代码错误(错别字)外,您还需要寻求运行(这是探索应用程序php错误处理和监视的好机会),您仍然需要将控制器的输出数据传递到视图。
这可以称为查看模型,或者仅仅是对象(从广义上讲)持有要查看的数据(视图渲染)。 Just 需要
/ include
-ing(html布局)模板文件不够,因为它们可能包含HTML结构,但不包含控制器的输出数据。在模板的级别上,这通常是在变量中,例如超文本文档的标题:
<title>
<?= htmlspecialchars($title, ENT_QUOTES | ENT_HTML5) ?>
</title>
如果这是函数的主体,则函数定义将是:
function outputHeader(string $title): void {
# ...
}
由于我们没有需要模板文件,因此我们没有函数这只是模范。但是,我们可以创建一个通用函数,该函数处理需要模板文件并将变量传递到模板(比较 代码>
)。在该层中,您还可以执行一些地面级别错误处理(
尝试{} catch(throwable $ throwable){}
等)。对于初学者,您可以在 View 类中收集并将此类代码分组。
您也可能想要防止的是将视图绑定在控制器的构造方法( Controller :: __ construct()
,简称CTOR)中。它迫使您拥有命名的视图(始终相同)使控制器取决于该视图。
这意味着您无法将任何视图配置为任何控制器。虽然在大多数情况下允许在混凝土实践中允许任何对任何关系的关系都是没有意义的,但它允许您实际具有层界限并不要太紧密(比较: spaghetti代码 1 ),并在更高级别上编写代码(在抽象等级中,比较间接层的层)。
HTTP应用程序中的一个示例是进行内容谈判。这将发生在请求处理的级别上(示例中的更多路由器),例如HTTP客户端请求JSON而不是HTML。现在,HTML模板在这里不适合。但是,如果不是视图模板,控制器仍然可以完成工作。
为了使事物更加灵活(因此您可以更大的扩展使用),MVC模型的一个好处是通过控制器使用(并以某种程度地将模型的结果)使用。它可以帮助您定义这三个之间的清晰边界,并使它们彼此之间的分开更多(不太耦合)。
然后,路由可以协商并确定要汇集的内容,与您的示例中的示例相似,但与视图(模板)进行了扩展,可以为每个路由分配一个布局/模板。
由于这将与控制器相当 - 只是为了视图 - 让我们看看当前控制器不仅在视图中占据了位置(如果您发现缺陷或错误,请环顾四周,请环顾四周,他们通常不是一个地方,也不是一个人)。
当您已经配置路由器中的路由时,您将实际路由放入 Controller base-class( Controller :: get($ route,$ controler)) 。类似于
__构造()
方法,这使控制器实现取决于路由,甚至实现路由。这很令人费解,肯定会变得尴尬。当您添加更多路线时,问题也存在问题,您会放松控制哪一个在每个控制器等内完成匹配时匹配。简而言之,虽然代码可能起作用,但在我看来,在另一个地方可能会受益。因为这是关于路由的,我脑海中脑海中的第一名将是路由器本身。然后,路由器可以完成实际工作,“执行路由”:
$router = new Router(); # <-- bootstrap
$router->get('/', 'home.contr.php'); # <-- prepare
$router->get('/home', 'home.contr.php'); # <-- prepare
$router->get('/about', 'about.contr.php'); # <-- prepare
$router->get('/portfolio', 'projects.contr.php'); # <-- prepare
$router->route(); # <-- do the work here
路由器 get()
方法可以从外部保持不变,但是您只需将路线存储在内部,当您调用<<时代码> route()方法,该配置与您的请求实现匹配。
然后,您可以使用视图名称扩展路由器配置。
那时,您仍然可以将路由绑定到控制器和视图,但是您有一个中心位置(已配置/参数化)。控制器和视图彼此更加独立,您可以将自己的实现集中到比现在进入路由器的整体接线。
最后,在这里时,您的示例还显示了它对文件系统的依赖性,您为控制器和视图模板提供了一定的文件命名约定。虽然隐含地将代码放入文件中是必不可少的,但至少在您可以依靠PHP自动加载的控制器级别上的示例中。虽然您想自己写所有内容(例如不使用现成的MVC库),但我仍然建议使用某些标准,例如 autolododer(psr-4)并且作为天生的懒惰,使该应用程序成为 composer project (它具有 composer.json
file)为作曲家允许您配置自动加载器,并且有一个定义明确的过程(您还可以更轻松地引入在应用程序逻辑中,您肯定需要的第三方库,因此这只是在很肯定的意义上是有意义的,只需使用Composer AutoLoader而无需任何要求)即可。
因此,您可以说控制器基本上是一个具有至少单个方法的类方法,而不是硬链接控制器PHP文件路径,而是该路由器可以调用的单个方法。随着自动加载器的操作,路由配置只需要引用该类别/方法和PHP,然后小心地加载课程。可以用。也许初学者的一个好的中间地面是每个班级有一个控制器,并且需要将其设备一个接口,以便您拥有合同(比较:编程与接口 1 ,2, 3 , 4 , 5 , 6 , 7 等)。然后,您可以简单地传递class-name并在 route()
方法中处理实例化。
$router->get(
/* route */ '/',
/* $controller */ MyApp\MVC\Crontroller\Home::class,
/* $viewName */ 'home'
);
<?php
namespace MyApp\MVC\Controller;
class Home implements Interface {
# ...
}
<?php
namespace MyApp\MVC\Controller;
interface Interface {
public function invoke(InputParameter $params): InvocationResult
}
然后, route()
可以检查接口以验证某些类可用作控制器( instanceof
),并且会知道如何 Invoke()控制器通过传递输入参数以接收可以进一步委派给模板层的结果。
还可以通过引入 InputParameter 和 InvocationResult 实现(类/接口)来实现这一目标,从而有助于定义控制器部分的层边界。
然后,您可以为视图层做类似的操作较少的工程,首先使用控制器尝试,然后在路由中进行委派,直到您更多地了解实际要求(会话处理,身份验证,内容调用,重定向等)。
归根结底,您必须在这里做出自己的决定。
下一步建议
- 添加至少可以从开发环境中运行的至少一个测试标记“使用单个键盘 /单击”和简单的OK / FAIL结果(例如,您在Shell中执行的简单PHP脚本)
- 考虑如何考虑如何为了改善错误处理,您可以更快地了解缺陷(例如,引入异常并
- 首先修复错误,您的代码实际上应该首先运行(它可能无法完整地产生预期的结果,但至少应该运行 - 您的示例不得)
- 初始化作曲家/添加
composer.json
到您的项目 - ,然后将代码更改为您的喜好,这可以使其首先进行测试受益(比较单位测试)
我已经找到了使用SWRL规则来执行此操作的方法。我的事情可能还有另一种使用财产链的方式,但我没有深入研究。
我这样做的方式需要安装插件才能使用SWRL规则,然后转到Windows - &gt;选项卡,然后选择SWRL选项卡。
然后,这很容易,只需一些Google即可查看语法并编辑一些预制的Google搜索规则。
最糟糕的解决方案是使用堆栈小部件,添加圆形容器
并设置 headingRowColor
透明。
我设置 headingRowheight
60和圆形容器
高度为40,所以我需要将圆形容器
margin(60-40)/2 = 10设置为使其成为垂直中心。
@override
Widget build(BuildContext context) {
TextStyle cellStyle = TextStyle(color: Colors.white);
TextStyle rowHeaderStyle = TextStyle(color: Colors.greenAccent);
return Padding(
padding: const EdgeInsets.all(8.0),
child: Stack(
children: [
// Add rounded container
Container(
width: MediaQuery.of(context).size.width,
// set height 40
height: 40,
margin: EdgeInsets.symmetric(vertical: 10,horizontal: 14),
decoration: BoxDecoration(
color: Colors.blueGrey,
borderRadius: BorderRadius.circular(20)
),
),
Container(
width: MediaQuery.of(context).size.width,
child: DataTable(
columnSpacing: 35,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(20), // this only make bottom rounded and not top
color: const Color(0xE61B1D1C),
),
// set heading row height 60
headingRowHeight: 60,
headingRowColor: MaterialStateProperty.all<Color>(Colors.transparent),
columns: [
DataColumn(label: Text("Referral Code", style: TextStyle(fontWeight: FontWeight.w400, fontSize: 12, color: Color(0xF2979797)), softWrap: true, textAlign: TextAlign.center,)),
DataColumn(label: Text("Share (%)\nYou-Friend", style: TextStyle(fontWeight: FontWeight.w400, fontSize: 12, color: Color(0xF2979797)), softWrap: true, textAlign: TextAlign.center,)),
DataColumn(label: Text("Friends", style: TextStyle(fontWeight: FontWeight.w400, fontSize: 12, color: Color(0xF2979797)))),
DataColumn(label: Text("Vol. (USD)", style: TextStyle(fontWeight: FontWeight.w400, fontSize: 12, color: Color(0xF2979797)))),
],
rows: [
DataRow(cells: [DataCell(Text('ADHJKGO',style: rowHeaderStyle,)), DataCell(Text('100-0',style: cellStyle,)), DataCell(Text('0',style: cellStyle)), DataCell(Text('100',style: cellStyle))]),
DataRow(cells: [DataCell(Text('CXMDJEO',style: rowHeaderStyle)), DataCell(Text('50-50',style: cellStyle)), DataCell(Text('0',style: cellStyle)), DataCell(Text('2000',style: cellStyle))]),
],
),
),
],
),
);
}
中构建它
您可以在阅读时通过日期变量读取它。
这是动态代码,您也不需要硬码日期,只需将其附加到路径上
>>> df.show()
+-----+-----------------+-----------+----------+
|Sr_No| User_Id|Transaction| dt|
+-----+-----------------+-----------+----------+
| 1|paytm 111002203@p| 100D|2022-06-29|
| 2|paytm 111002203@p| 50C|2022-06-27|
| 3|paytm 111002203@p| 20C|2022-06-26|
| 4|paytm 111002203@p| 10C|2022-06-25|
| 5| null| 1C|2022-06-24|
+-----+-----------------+-----------+----------+
>>> df.write.partitionBy("dt").mode("append").parquet("/dir1/dir2/sample.parquet")
>>> from datetime import date
>>> from datetime import timedelta
>>> today = date.today()
#Here i am taking two days back date, for one day back you can do (days=1)
>>> yesterday = today - timedelta(days = 2)
>>> two_days_back=yesterday.strftime('%Y-%m-%d')
>>> path="/di1/dir2/sample.parquet/dt="+two_days_back
>>> spark.read.parquet(path).show()
+-----+-----------------+-----------+
|Sr_No| User_Id|Transaction|
+-----+-----------------+-----------+
| 2|paytm 111002203@p| 50C|
+-----+-----------------+-----------+
尝试此示例:
server.py
(服务器等待 msg1
和 msg2
并相应地响应):
async def runServer():
server = await websockets.serve(onConnect, "localhost", port=8765)
print("Server started listening to new connections...")
await server.wait_closed()
async def onConnect(ws):
try:
while True:
message = await ws.recv()
if message == "msg1":
await ws.send("response from server 1")
elif message == "msg2":
await ws.send("response from server 2")
except websockets.exceptions.ConnectionClosedOK:
print("Client closed...")
if __name__ == "__main__":
asyncio.run(runServer())
client.py.py
(首先发送 msg1
,打印响应,然后 发送 msg2
并打印响应):
async def connect():
async with websockets.connect(
"ws://localhost:8765",
) as ws:
print("Connected to the switch.")
await ws.send("msg1")
response = await ws.recv()
print("Response from the server:", response)
await ws.send("msg2")
response = await ws.recv()
print("Response from the server:", response)
if __name__ == "__main__":
asyncio.run(connect())
客户端打印:
Connected to the switch.
Response from the server: response from server 1
Response from the server: response from server 2
因此,我找到了解决方案:
我不必模拟 uservice.js
文件,而是 keycloak-js
-module。为此,我创建了一个名为 __模拟__
的文件夹,然后放入模拟的模块中。开玩笑会自动知道从模拟文件夹而不是节点模块调用keycloak-js。
src/模拟/keycloak-js.js:
class Keycloak {
token = "token available";
url = null;
realm = null;
clientId = null;
tokenParsed = {
preferred_username: "dummy user",
}
constructor(keycloakConfig) {
this.url = keycloakConfig.url;
this.realm = keycloakConfig.realm;
this.clientId = keycloakConfig.clientId;
}
login = () => {
this.token = "Logged in";
}
logout = () => {
this.token = null;
}
updateToken = () => {
this.token = "Logged in";
return new Promise((resolve, reject) => {
if (!!this.token) {
resolve();
} else {
reject();
}
})
}
init = (startupConfig) => {
}
hasRealmRole = (role) => {
return true;
}
}
export default Keycloak;
Amy和Pineapple☑️错误线:MongonetWorkerror:连接机构在ConnectionFailureError 取消了
const mongoose = require("mongoose");
mongoose.connect("mongodb://localhost:27017/fruitsDB",{useNewUrlParser: true});
const fruitSchema = new mongoose.Schema({
name: {
type: String,
required: [true, "Please check your data entry, no name specified!"]
},
rating: {
type: Number,
min: 1,
max: 10
},
review: String
});
const Fruit = mongoose.model("Fruit", fruitSchema);
const pineapple = new Fruit({
name: "Pineapple",
rating: 9,
review: "Great fruit"
});
const personSchema = new mongoose.Schema({
name: String,
age: Number,
favouriteFruit: fruitSchema
});
const Person = mongoose.model("Person", personSchema);
const person = new Person({
name: "Amy",
age: 12,
favouriteFruit: pineapple
});
pineapple.save();
person.save();
您只需要保存菠萝和人 最后 对我有用。
PHP全局变量 $ _ POST
包含发布到服务器的所有数据。当前, HardWareComputername
只是客户端的变量。您需要将其添加到您的表单中,以便将其发布到服务器上。只有这样,您就可以从 $ _ POST ['HARDWARECOMPUTERNAME']
中读取它。
做到这一点的一种方法:
-
向您的表格中添加另一个隐藏元素:
&lt; input type =“隐藏” name =“ hardwarecomputername” id =“ computername”&gt;
-
对话框结果后,将输入值添加到新创建的元素:
if(hardwarecomputername){ document.getElementById(“ computername”)。value = hardwarecomputername; document.getElementById(“ ComputerRenameForm”)。submit(); }
完成:
<form id="computerRenameForm" action="computerRename" method="post">
<input type="hidden" name="rename" value="">
<input type="hidden" name="computerID" value="<?= htmlspecialchars($computer->id) ?>">
<input type="hidden" name="hardwareComputerName" id="computerName">
</form>
<button onclick="confirmComputerRename()"><i class="bi bi-trash-fill"></i> Umbenennen</button>
<script>
function confirmComputerRename()
{
(async () => {
const { value: hardwareComputerName } = await Swal.fire({
html: "Zum Umbenennen muss der Computer online sein.<br>Das Gerät wird neu gestartet.",
icon: 'warning',
input: 'text',
inputAttributes: {maxlength: 15},
showCancelButton: true,
confirmButtonText: 'OK',
confirmButtonColor: '#ff0000',
cancelButtonText: 'Abbrechen',
reverseButtons: false
})
if (hardwareComputerName) {
document.getElementById("computerName").value = hardwareComputerName;
document.getElementById("computerRenameForm").submit();
}
})()
}
</script>
没关系,这只是我花了一段时间才弄清楚了,对不起。
#include&lt; stdio.h&gt;
int var = 1;
int var1 = 2;
int main()
{
while (var<100)
{
var+=var1;
var1+= var;
printf("%d\n", var);
}
}
好的,这完全无关。
- 因此,基本上,您需要提出一个将提供HTML代码的GET请求。
- 在此HTML代码中,您会找到一个CSRF令牌。您将使用Regex将其放入字符串中。
- 您将创建一个返回用户名,密码和CSRF代币的POST登录请求。
您现在已记录!!!
关于处理cookie,只要保留相同的retclient对象,RestSharp就会自动进行。我将它们放在字符串数组中,然后使用string.format在请求中使用它们
您必须导入特质 std :: io :: Read
,然后可以调用 read> read :: read_to_to_string
才能读取文件的内容。
use std::fs::File;
use std::io::{BufReader, Read};
fn main() {
let mut input: BufReader<File> = BufReader::new(File::open("cube.obj").expect("didn't work"));
let mut str = String::new();
input.read_to_string(&mut str).expect("cannot read string");
println!("input: {}", str);
}
if (Capacitor.isNativePlatform()) {
// Native app running on Android or iOS
}
转到Azure Portal - &gt; app-&gt;网络 - &gt;访问限制 - &gt;配置访问限制
前门考虑了后端池中的所有后端,即使健康探索了任何一个人,它们失败了,流量在所有方面均匀分布。请参阅
3.尝试禁用
emforcecercertificatectificatenamecheck 来自Azure门户,并在添加到Orgin时检查您是否启用
cerficate主题名称验证
必须是 启用 这个问题。4.试图通过此 azure前门路由不工作 gitaranisharmsft-4262 的
:
学分 前门#先决条件“ rel =” nofollow noreferrer“> https://learn.microsoft.com/en-us/azure/frontdoor/quickstart-create-front-door#prerequisites
https://learn.microsoft.com/en-us/azure/frontdoor/routing-methods
This error may cause If your open public API is restricted from public access on Azure App Service. Your application's IP address that you are using to access the app service is not whitelisted or calls may be blocking.
Go to azure portal -> app -> Networking ->Access Restriction -> Configure Access Restrictions
Front Door considers all backends in a backend pool to be healthy even if health probes for any one of them fail, and traffic is distributed evenly across them all. Please refer Health probes
3.Try to disable
EnforceCertificateNameCheck
from the Azure portal and while adding to Orgin check whether you are enableCerficate subject name validation
must be enable for Troubleshooting this issue.4.Try to add virtual directory /path in your app service by this Azure front Door routing not working throws error credits by GitaraniSharmaMSFT-4262
For your Reference :
https://learn.microsoft.com/en-us/azure/frontdoor/quickstart-create-front-door#prerequisites
https://learn.microsoft.com/en-us/azure/frontdoor/routing-methods
Azure前门一直在路线一直到一个起源